How to change HTML Object element data attribute value in javascript

前端 未结 6 980
清酒与你
清酒与你 2020-11-30 07:34

How do you change HTML Object element data attribute value in JavaScript?

Here is what i am trying



        
      
      
      
6条回答
  •  独厮守ぢ
    2020-11-30 08:20

    The behavior of host objects is due to ECMA262 implementation dependent and set attribute by setAttribute() method may fail.

    I see two solutions:

    1. soft: element.data = "http://www.google.com";

    2. hard: remove object from DOM tree and create new one with changed data attribute.

    提交回复
    热议问题