0
我有一個從outerHTML獲得的字符串。它記錄,如:使用jquery從html中提取屬性
var responseHtml = jQuery(data).find("#response")[0].outerHTML;
console.log(responseHtml);
Log:
<div id="response" hello="world" big="span" hey="there"><\/div>"
<div class="clear"></div></div>
我想獲得它的格式,所以我可以進入「世界」,如:values["hello"] => "world"
我在這裏停留。什麼是實現它的適當方式?
首先,所有這些屬性都是無效的,你應該使用數據屬性。其次,你應該簡單地將它們作爲$('#response')。data('big')'來訪問它們。 – adeneo
你可以用'$('#response')。attr('hello')' –
非常感謝!!! – senty