有什么方法可以在所有 ID 有名称的 ID 上使用 jquery 更改 css 代码:
google-visualization-errors-%
所以 % 是更多的词......等等 google-visualization-errors-all-1, google-visualization-errors-2
所以当某些 ID 有第一个关键字时:google-visualization-errors... 将 css 设置更改为 display:none;
最佳答案
您可以使用 ^=
来选择具有指定属性且值恰好以给定字符串开头的元素。
尝试:
$('*[id^="google-visualization-errors-"]').css("display","none");
或更简单
$('*[id^="google-visualization-errors-"]').hide();
关于javascript - 如何不使用 google-visualization-errors-% 显示 ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24555838/