javascript - Alternative to document.getElementById().setAttribute() function -


क्या निम्न पंक्ति करने का कोई विकल्प है:

  document.getElementById ("btn ") .setAttribute (" onclick "," save ("+ id +"); ");  

यह रेखा मूल रूप से onclick () को एक बटन की घटना को बदलता है जैसे: save (34); , सहेजें (35); आदि। हालांकि यह IE 7 और 6 में विफल रहता है लेकिन IE 8 और Firefox में काम करता है।

मैं इसके लिए jquery का भी उपयोग कर सकता हूं।

यदि आप jQuery का उपयोग कर सकते हैं, तो:

  $ ("# btn")। (फ़ंक्शन () {सेव (आईडी);})  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -