Best unobtrusive way to add JQuery confirm to an arbitrary element

前端 未结 3 706
借酒劲吻你
借酒劲吻你 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:17

    Answer to 1: Yes they will.

    Answer to 2: You could add CSS class called requires-confirm and add data-description or data-meta attribute with additional text that you'd use in your handler.

    Why both?

    In case you have more than one functionality integrated in your page. CSS class tells which functionality should be added and data- attribute holds metadata to use.

    If you'll only be using one single functionality, you can easily omit CSS reference and just use the data- attribute of course.

提交回复
热议问题