Writing Image Gallery (Javascript) [closed] - javascript

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I just want to ask if anyone could help me write that image gallery?
Screenshot how it should look like: link
This is what i come up with:
jsgalerija.html
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>JS Galerija</title>
<link rel="stylesheet" type="text/css" href="jsGalerija.css" />
<script type="text/javascript" src="jsGalerija.js"></script>
</head>
<body onLoad="galerija();">
<table class="galerija">
<tr><th>Seznam</th><th>Slika</th></tr>
<tr>
<td id="seznam"></td>
<td id="slika">Klikni na sliko v seznamu!</td>
</tr>
</table>
</body>
</html>
jsGalerija.js
function galerija()
{
images = new Array();
images[0]="slike/image1.jpg"
images[1]="slike/image2.jpg"
images[2]="slike/image3.jpg"
images[3]="slike/image4.jpg"
for(i=0; i<=3; i++)
{
document.getElementById('seznam').innerHTML = '<IMG SRC="' +images[i]+ '"><br />';
document.getElementById('slika').innerHTML = '<IMG SRC="' +images[i]+ '"><br />';
}
}
If anyone can help me, I would really appreciate it. Thanks in advance.

As stupid as this answer may seem, you can use a code snippet from a site like Dynamic Drive:
http://www.dynamicdrive.com/dynamicindex4/indexb.html

Related

How Do I Get Image Src Attribute? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I found a lot of questions like this but none of them are helpful
The problem is when I try console.log(document.getElementById("image").getAttribute("src"))
it just return null
how do actually get image src attribute?
HTML code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Endless Discuss</title>
<link rel="stylesheet" href="style.css">
</head>
<body class="dark-theme">
<button class="theme" onclick="change_theme()"><img src="theme/Dark.png" class="logo" id="image"></button>
<textarea class="input-post" id="comment-content" placeholder="Type message here..." onkeypress="enter(event)"></textarea><br>
<button class="submit" id="submit_button" onclick="post_comment()">Send</button>
<script src="script.js"></script>
</body>
</html>
Just use src attribute of getElementById() method result.
console.log(document.getElementById("image").src);
Just put this in your JS code
var youtubeimgsrc = document.getElementById("ImageTagId").src;
I have coded up a simple get image source sample code. You may have a look at it
function myFunction() {
document.getElementById("label").innerHTML = document.getElementById("myImg").src;;
}
<img id="myImg" src="https://previews.123rf.com/images/aquir/aquir1311/aquir131100316/23569861-sample-grunge-red-round-stamp.jpg" width="107" height="98">
<button onclick="myFunction()">Click me to get image source</button>
<p id="label"></p>
use Jquery: $("#image").attr('src');

HTML Javascript displaying Japanese characters incorrectly?

My HTML
<head >
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<div id="Target">食べる</div>
This displays perfectly fine .
document.getElementById("Target").innerHTML = "会う";
But once I use javascript to change the value of "Target" I get ��.
I'm fairly inexperienced when it comes to both javascript and encodings, so I apologize in advance if this is an easy fix.

select all text in JavaScript [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i need to select all text in my html code and surround them with <span> tag in JavaScript
convert this code:
<!DOCTYPE html>
<html>
<body>
<h1>Heading</h1>
<p>paragraph.</p>
</body>
</html>
to this:
<!DOCTYPE html>
<html>
<body>
<h1><span id="text">Heading</span></h1>
<p><span id="text">paragraph.</span></p>
</body>
</html>
how can i do this?
You can wrap your text with this fonction :
$(selector).wrapInner( "<span class=\"text\"></div>");
where selector target the tag you want
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function(e) {
$('html').prependTo('<script>');
});
</script>
</head>
<body>
hi
</body>
</html>

how to pick value in jquery [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
i have build a small function whose work to get value in alert box but i want to pick only 5 character from starting. here is my function
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
$(function (){
$(".hhh").click(function(){
$(this).html()
})
})
</script>
</head>
<body>
<div class="hhh">dd:ff:aa</div>
</body>
</html>
You could use the substring method:
$('.hhh').click(function() {
alert($(this).html().substring(0, 5));
});
Obviously checking the length of the string before calling substring to ensure that it has at least 5 characters could be a good check to do.
Do you mean substr ?
$(this).html().substr(0, 5);

Mozilla Firefox bug or ..? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I wrote the code and saw a bug in firefox and little bug in chrome
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mozila Firefox</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function(){
$(window).scroll(function(){
if ($(window).scrollTop() == $(document).height() - $(window).height()){
alert('1');
}
});
});
</script>
</head>
<body>
CONTENT FOR SCROLL
</body>
</html>
When I scroll this page in firefox i getting bug which covers the black transparent background browser.
In chrome just more and more alerts.
Close your tabs in firefox!
Live: http://forum.xeksec.com/habr/mozilla_crash_or_wtf/
See https://bugzilla.mozilla.org/show_bug.cgi?id=723532
Edit :
The above doesn't always work... In fact, I've checked some solutions around, including here in Stack Overflow. What other usually advice have the same problem (eg Alert using Jquery when Scroll to end of Page)
I'm using FF11 on Ubuntu.
I think this was a performance issue. If you put your maxScroll in a variable it works (at least for me)
Here's my code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Mozila Firefox</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script>
$(function(){
var maxScroll = $(document).height() - $(window).height();
$(window).scroll(function(){
if ($(window).scrollTop() == maxScroll){
alert('1');
}
});
});
</script>
</head>
<body>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</body>
</html>

Categories