在这个小提琴中:http: //jsfiddle.net/m7q3H/52/
我正在访问 div“toupdate”中返回的 html。我希望它会返回, <script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6343621.js"></script>
而是返回:
<script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6343621.js"></script><a name="pd_a_6343621" style="display: inline; padding: 0px; margin: 0px;"></a><div class="PDS_Poll" id="PDI_container6343621"><div style="margin-bottom: 0px; margin-top: 0px;" name="PDI_form6343621" id="PDI_form6343621"><div class="pds-box"><div class="pds-box-outer"><div class="pds-box-inner"><div class="pds-box-top"><div class="pds-question"><div class="pds-question-outer"><div class="pds-question-inner"><div class="pds-question-top"> New Poll</div></div></div></div><div class="pds-answer"><span id="pds-answer6343621"><span class="pds-answer-group"><span class="pds-answer-input"><input class="pds-radiobutton" type="radio" id="PDI_answer28688772" value="28688772" name="PDI_answer6343621"></span><label for="PDI_answer28688772" class="pds-input-label"><span class="pds-answer-span">Answer A</span></label><span class="pds-clear"></span><br></span><span class="pds-answer-group"><span class="pds-answer-input"><input class="pds-radiobutton" type="radio" id="PDI_answer28688773" value="28688773" name="PDI_answer6343621"></span><label for="PDI_answer28688773" class="pds-input-label"><span class="pds-answer-span">Answer B</span></label><span class="pds-clear"></span><br></span><span class="pds-answer-group"><span class="pds-answer-input"><input class="pds-radiobutton" type="radio" id="PDI_answer28688774" value="28688774" name="PDI_answer6343621"></span><label for="PDI_answer28688774" class="pds-input-label"><span class="pds-answer-span">Answer C</span></label><span class="pds-clear"></span><br></span></span></div><div class="pds-vote"><div class="pds-votebutton-outer"><a id="pd-vote-button6343621" class="pds-vote-button"><span>Vote</span></a><span class="pds-links"><a href="javascript:PD_vote6343621(1);" class="pds-view-results">View Results</a><br><a href="http://polldaddy.com/signup-free/?ad=poll-front" target="_blank" class="pds-pd-link">Polldaddy.com</a><span class="pds-clear"></span></span><span class="pds-clear"></span></div></div></div></div></div></div></div><img src="http://pixel.quantserve.com/pixel?a.1=p-18-mFEk4J448M&a.2=p-ab3gTb8xb3dLg&labels.1=type.polldaddy.poll" style="display: none;" border="0" height="1" width="1" alt="Quantcast"></div><div id="PD_superContainer"></div>
这段代码来自哪里?我可以通过单独的 jquery 方法而不是 .html() 访问所有这些 javascript 代码吗?
小提琴代码:
<body>
<div id="toupdate">
<script type="text/javascript" charset="utf-8" src="http://static.polldaddy.com/p/6343621.js"></script>
</div>
</body>
$(document).ready(function() {
console.log('HTML is '+$('#toupdate').html());
});