Bug Tracker

Opened 13 years ago

Closed 13 years ago

#6405 closed bug (worksforme)

.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:



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.


<script type="text/javascript"> $(document).ready(function(){

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


}); </script>

<div id="test">

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


Change History (3)

comment:1 Changed 13 years ago by dmethvin

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?

comment:2 Changed 13 years ago by dioniss1

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.

comment:3 Changed 13 years ago by dmethvin

Resolution: worksforme
Status: newclosed
Note: See TracTickets for help on using tickets.