i am replacing the img src attribute using javascript
my code is
<div class="reader" id="reader1"></div>
<img src="images/img_001.jpg" alt="image" id="image1"/>
</div>
and javascript code
$("#image1").attr("src").replace("images/img_001.jpg", "images/img_002.jpg");
the src attribute is not replacing
You don’t need to call replace()
, just set the new src:
$("#image1").attr("src", "images/img_002.jpg");
See http://api.jquery.com/attr/#attr2 :
$("#image1").attr("src", "images/img_002.jpg");
You can directly set the value of src
with:
$("#image1").attr("src", "images/img_002.jpg");
Have a look at jQuery doc for attr()
.
I have been working on making a form that uploads an image through ajax with php doing the upload. For some background I am having an issue where the xhr.readyState and .Status seem to run and upload....
I have been working on making a form that uploads an image through ajax with php doing the upload. For some background I am having an issue where the xhr.readyState and .Status seem to run and upload....
This code works perfect for crome and firefox.. but error in IE8 if($('#soundcheck').is(':checked')){ //alert('checked'); var audio = document.createElement('...
This code works perfect for crome and firefox.. but error in IE8 if($('#soundcheck').is(':checked')){ //alert('checked'); var audio = document.createElement('...
Possible Duplicate: Javascript outer scope variable access I have a javascript module that looks something like below. The main issue I'm having is how to access variables in the "this" scope ...
Possible Duplicate: Javascript outer scope variable access I have a javascript module that looks something like below. The main issue I'm having is how to access variables in the "this" scope ...
i can find text of an element by using this code.but i want to find a single word any where in my page if mouse hovers on that word for certain time. $(document).bind("mouseover", function (e) { ...
i can find text of an element by using this code.but i want to find a single word any where in my page if mouse hovers on that word for certain time. $(document).bind("mouseover", function (e) { ...