We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<ul> <li class='target'> <span>test</span> </li> </ul>
class
li
ul
js
jQuery
The text was updated successfully, but these errors were encountered:
挽尊
var ul = document.querySelector('ul'); ul.addEventListener('click', function (e) { var target = e.target, f = function (t) { console.log(t); var className = t.className; if (t.tagName === 'LI' && className && className.indexOf('target') >= 0) { alert(t.innerHTML) } else if(t != ul) { f(t.parentNode) } }; f(target) }, false)
Sorry, something went wrong.
`var ul = document.querySelector('ul'); ul.addEventListener('click', function (e) { var target = e.target; (function(i){ var cln=i.className?i.className:' '; if(i.tagName==="LI" &&cln.indexOf('target')>=0){ alert(i.innerHTML); } })(target); }
No branches or pull requests
class
为 target 的li
可以 alert 出其所含内容(如上方代码点击弹出“test”)ul
动态新增li
元素的情况下,也要有相同效果js
实现,不使用jQuery
The text was updated successfully, but these errors were encountered: