About jQuery append() and how to check if an element has been appended

前端 未结 6 1035
天命终不由人
天命终不由人 2021-01-11 10:21

I made a very simple button click event handler, I would like to have

element be appended when button clicked, you can check my code

6条回答
  •  长发绾君心
    2021-01-11 11:06

    1) jsFiddle loads in MooTools by default, you need to include jQuery for this to work. There is not a reason in the world why that example wouldn't work. (Assuming that the $ is actually mapped to the jQuery object, that is.)

    2) You can check the nextSibling of a DOMElement, or use the next() jQuery method, like so:

    if(!$('#something').next().length) {
       //no next sibling.
    }
    

提交回复
热议问题