1

http://jsfiddle.net/uGyTB/

var s = $("<li><a href='index.html'><h3>hello</h3></a></li>");
alert(s.html());​

li要素が作成されていないことを示します。なんで?

4

2 に答える 2

8
于 2012-12-16T21:48:45.853 に答える
0

In an HTML document, .html() can be used to get the contents of any element. If the selector expression matches more than one element, only the first match will have its HTML content returned. Consider this code:

$('div.demo-container').html();

In order for the following 's content to be retrieved, it would have to be the first one with class="demo-container" in the document:

<div class="demo-container">
  <div class="demo-box">Demonstration Box</div>
</div>

The result would look like this:

<div class="demo-box">Demonstration Box</div>
于 2012-12-16T22:04:55.793 に答える