Set value for dynamic class in CSS or jQuery

ぐ巨炮叔叔 提交于 2020-01-06 08:14:23

问题


I have Facebook Comment module installed in WordPress, for some unknown reason Facebook made some changes and now the class I need to change is dynamically as for example #feedback_7324324h, #feedback_kjwyhr, #feedback_234734dsfn and so on, the only equal part is #feedback_ is there any way or chance to set width to 100% on any element that holds #feedback_ as class?


回答1:


You can use the attribute starts with selector (the hash at the beginning of the class seems strange ?)

jQuery('[id^="feedback_"]').css('width', '100%' );



回答2:


Yeah like this

$("[class^='#feedback_']")

Docs --> https://api.jquery.com/attribute-starts-with-selector/



来源:https://stackoverflow.com/questions/22491401/set-value-for-dynamic-class-in-css-or-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!