Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的要求是找到与 'vrr' 匹配的 id,所以我使用 * 来表示它,但它不适用于美元,猜猜为什么这不起作用?
HTML:
<div id="vrrcss">you</div>
脚本
$(function(){ $('[id$*=vrr]').text('me') })
$=匹配以指定值结尾的属性。 'vrrcss'不以'vrr'.
$=
'vrrcss'
'vrr'
请改用^=(attribute started with)或*=(attribute contains)。
^=
*=
如果要更改元素“vrr”的文本,请尝试以下操作,或者只是...
$("[id^=vrr]").text('Me');