我有一個標籤象下面這樣:正則表達式?
<p id="questionText"><span class="qn" id="qn"> 1 </span> hello? * </p>
我想從文本("Hello"
)。
我已經做了,成功地用下面的代碼,但.textContent
沒有在IE
questionText = $('questionText-').textContent;
questionText = questionText.replace(/\d+/g,"");
questionText = questionText.replace("*","");
return questionText.replace(/^\s*|\s*$/g,'') ;
工作,我如何更改代碼,使其工作在兩個?
'$('questionText - ')'不是一個有效的選擇器。如果您使用jQuery或$('questionText')'',如果'$'只是別名'getElementById',您可能想使用'$('#questionText')'。 – ThiefMaster 2011-04-06 11:35:57