ajax中dom,在(jQuery)ajax请求中获取当前脚本DOM对象
涉及兩個步驟簡單的解決方案:
1)找出哪些元素腳本標簽是
2)發(fā)現,元素
的代碼中的前一個兄弟:
var scripts = document.getElementsByTagName("script");
var current = scripts[scripts.length-1];
var previousElement = current.previousSibling;
// there may be whitespace text nodes that should be ignored
while(previousElement!==null && previousElement.nodeType===3) {
previousElement = previous.previousSibling; }
if(previousElement!==null) {
// previousElement is
in this case$(document).ready(function(){
$(previousElement).someEffect(params);
});
}
這是不錯的網絡編程?不可以。您應該知道哪些元素應該根據您生成的內容對其應用效果。如果你有一個帶有id的div,那么這個id是唯一的,你的生成器可以告訴如果它生成了div,它也必須生成為其設置jQuery效果的js。
但讓我們忽略它;它工作嗎?就像一個魅力。
總結
以上是生活随笔為你收集整理的ajax中dom,在(jQuery)ajax请求中获取当前脚本DOM对象的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: css里calculate,calc()
- 下一篇: oracle ajax储存过程分页,创建