Best unobtrusive way to add JQuery confirm to an arbitrary element

前端 未结 3 738
借酒劲吻你
借酒劲吻你 2021-01-16 12:42

I\'m new to jquery, and am looking for a good unobtrusive way to add a jquery replacement for javascript \"confirm\" to a HTML elements. Specifically I want to be able to u

3条回答
  •  醉酒成梦
    2021-01-16 13:04

    personally, I use a specific class for things like that.

    The main reason is that they are easy to select with something like $('.confirm').each() or better $('.confirm').youConfirmPlugin(). Moreover, a css is easily added in a css file (where it belongs).

    if extra data is needed, then yes, use the data attribute in combination with the class.

提交回复
热议问题