使用jq中怎么拿到静态网页中嵌套的标签中的其他控件控件
建议一个笨办法 假设你是想拿 选择器的话 可以先将网页字符串输出。然后做字符串查找,再做选择器
描述有点没看懂。
<html>
<head></head>
<body></body>
</html>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var $htmlScript = $("#htmlScript");
// 打印脚本
console.log($htmlScript.text());
var htmlScriptContent = $htmlScript.text();
var $contentDiv = $(htmlScriptContent);
console.log($contentDiv.find("input").attr("id"));
console.log($contentDiv.find("div").attr("id"));
console.log($contentDiv.find("div").text());
});
</script>
<script type="text/html" id="htmlScript" value="hello script">
<div>
<input id="htmlInput" name="textHtml" type="text" value="hello input"/>
<div id="htmlDiv">this is a div</div>
</div>
</script>