Skip to main content

Bug Tracker

Side navigation

#6405 closed bug (worksforme)

Opened April 07, 2010 09:34AM UTC

Closed June 12, 2010 02:42AM UTC

.html() is returning wrong content

Reported by: dioniss1 Owned by:
Priority: Milestone:
Component: unfiled Version: 1.3.2
Keywords: .html() return wrong content Cc:
Blocked by: Blocking:
Description

Hello,

In the fallowing code I am changing the value of input to 2 and then I want to get the html content of div#test. But I am receiving:

<input name="name" value="myipa" type="text"><br />

<input name="property" value="1" type="text"><br />

The problem is that I am receiving the property input with value of 1. The actual value is 2.

Am I doing something wrong or this is bug ?

Please tell me how can I get the content with the changes.

Thank you in advance.


code:


<script type="text/javascript">

$(document).ready(function(){

$('div#test input[name="property"]').attr('value','2');

var html = $('div#test').html();

alert(html);

});

</script>

<div id="test">

<input type="text" name="name" value="myipa" />

<input type="text" name="property" value="1" />

</div>


Attachments (0)
Change History (3)

Changed April 10, 2010 11:54PM UTC by dmethvin comment:1

The problem is that (in IE at least) the value set is only reflected in the runtime property. If you use

.attr("value")
to get the value it will be correct.

Is there a reason that you were using

.html()
to get the live value, or were you just using that as a debugging tool?

Changed April 19, 2010 07:06AM UTC by dioniss1 comment:2

I was building tree view and wanted to move some of his "leaf", which content I change rapidly. So I try to use $(selector).html() to get the html of selector, but I found that I could use .prepend($(selector)) and the actual html was moved.

Thank you for your help.

Changed June 12, 2010 02:42AM UTC by dmethvin comment:3

resolution: → worksforme
status: newclosed