換種寫法為什么獲取不到內(nèi)容
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? var $content = $("h3").attr("html");
? ? ? ? ? ? $("#html").html($content)
? ? ? ? ? ? $("#text").text($content);
? ? ? ? </script>
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? var $content = $("h3").attr("html");
? ? ? ? ? ? $("#html").html($content)
? ? ? ? ? ? $("#text").text($content);
? ? ? ? </script>
2016-04-12
舉報(bào)
2016-04-13
最終原因是$("#html").html($content)你這句代碼后邊沒(méi)有分號(hào)
2016-04-12
var $content = $("h3").attr("html");h3元素中并沒(méi)有html這個(gè)屬性,所以$content獲取不到內(nèi)容。
2016-04-12
var $content=$("h3").html();
這樣就得到了h3中的元素,但是
$("#html").html($content)
$("#text").text($content);
這兩句話的執(zhí)行結(jié)果是一樣的
2016-04-12
var $content=$("h3").attr("html");
這句話中的html屬性值不存在,所以沒(méi)有內(nèi)容
2016-04-12
$("#html").html($content)
$("#text").text($content);
加粗的部分有誤,不是id選擇器,不能用"#"