what's the difference between and

后端 未结 3 1383
野性不改
野性不改 2020-12-03 15:35

what is the difference between

and

One uses

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 15:47

    when writing inline on click functions, we assigning the code to be executed in the form of string on click of the element.

    It is equivalent to eval('someFunction()'); we cannot write on click='someFunction' since it will be equivalent to eval('someFunction') which would do nothing. if you intend to bind a click handler to an anchor tag, dont forget to add a href='#' attribute to the anchor tag.

    There is no difference between assigning a click handler to span or divs as compared to anchor tag.

提交回复
热议问题