簡體   English   中英

在mootools或javascript中為標簽標記設置htmlFor屬性

[英]Set htmlFor property for a label tag in mootools or javascript

我想通過以下命令在mootools 1.3中創建一個新標簽:

new Element('lable', {
    'for':'chk_id',
    'html':'hello'
  }).inject(document.body);

標簽將使用“ hello”文本創建,但“ for”屬性不適用於標簽。 我測試了'htmlFor'屬性,我可以在Firebug中看到此屬性,但是它不起作用(我想檢查id ='chk_id'的輸入)。 mootools或javascript有解決方案嗎?

也許使用label而不是法語lable可能是一個不錯的起點。 只要確保for屬性與輸入元素的ID相匹配即可。

new Element("label[for=bar][text=bar]").inject(document.body);

在1.3中很好:) http://jsfiddle.net/Fw9hh/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM