chrome浏览器右键点橙色方框选择"审查元素"
document.querySelector('li[data-pre] > div.order-info > div.order-title.posr > div.order-num > span ').innerHTML
获取蓝色方框内的内容是获取不到(提示:VM419:1 Uncaught TypeError: Cannot read property 'innerHTML' of null).以下命令就可以获取到
window.parent.frames["hashframe"].document.querySelector('li[data-pre] > div.order-info > div.order-title.posr > div.order-num > span ').innerHTML这样就可以获取到"8"
---------------------------------------------------------------分割线
chrome浏览器右键点蓝色方框选择"审查元素"
document.querySelector("#wrapper > header > div > div.user-section.pull-left > div.pull-left.box.wm-poi-name.J-box.J-change-poi-wrapper > a > span").innerHTML
获取橙色方块内的内容获取不到(提示:VM590:1 Uncaught TypeError: Cannot read property 'innerHTML' of null)
如果是右键点击橙色方块"审查元素"则同样的命令就能获取到"****蛋糕"
问题1.在右键点蓝色方框选择"审查元素"后如何和获取到黄色框内的内容.
问题2.蓝色方框内的订单号为8,能不能用document.querySelectorALL指定元素下标实现读取7号订单.
Uncaught TypeError: Cannot read property 'innerHTML' of null)这个说明不能直接用这种方式获取iframe中的元素。
还是应该用分割线上面的那种写法来获取。
js
var cont=document.getElementById("content");
console.log('innerText cont= '+ cont.innerText);
console.log('innerHtml cont= '+ cont.innerHTML);
//以上两条都能输出span标签的值‘我是span标签的内容’;
jq
var cont=$("#content");
console.log(cont.val()); //输出 (无值);
console.log(cont.text()); //输出 ‘我是span标签的内容’;
***在JS中使用innerHTML时希望自己注意,不要写成了cont.innerHtml ,这样输出结果就是 undefined ;console.log(cont.html()); //输出 ‘我是span标签的内容’;