How to add an HTML attribute with jQuery

后端 未结 7 764
无人及你
无人及你 2020-12-03 11:34

Well, I have this jQuery image slideshow that uses the attribute \"control\" inside an . Seeing how it didn\'t validate I searched for a way to add this attribute i

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 11:55

    Since the jQuery version has been well covered here, I thought I'd offer something different, so here a native DOM API alternative:

    document.getElementById('previous').setAttribute('control','-6');
    

    Yes, I know you asked for jQuery. Never hurts to know the native way too. :o)

提交回复
热议问题