jQuery选择器 [英] jQuery Selectors
问题描述
我想从视图源中获取这个,例如:
< a href =javascript:validateCB ;>< img src =wwv_flow_file_mgr.get_file?p_security_group_id = 1343380920146312332& p_flow_id = 222& p_fname = submit_btn.gifalt =Submit Detailsborder =0/>
转换为jQuery选择器格式
var $ templateButtons = $('img [src ^ =wwv_flow_file_mgr]')。parent('a');
但这似乎不正确。
任何想法如何将上述视图源代码翻译成jQuery?
谢谢,
Tony。
您遇到了已知错误在jQuery v1.3.2 - jQuery试图解释图像路径使用其绝对URL,这意味着它比较的URL实际上以 http:// ...
您可以使用 * =
(它查找包含文本 wwv_flow_file_mgr,而不是以它开头):
var $ templateButtons = $('img [src * =wwv_flow_file_mgr]' ).parent('a');
I am trying to take this from view source, i.e.:
<a href="javascript:validateCB();"><img src="wwv_flow_file_mgr.get_file?p_security_group_id=1343380920146312332&p_flow_id=222&p_fname=submit_btn.gif" alt="Submit Details" border="0" />
into jQuery selector format
var $templateButtons = $('img[src^="wwv_flow_file_mgr"]').parent('a');
But this doesn't seem to be correct.
Any ideas how to translate the above view source code into jQuery?
Thanks, Tony.
The problem is with the attribute selector: $('img[src^="wwv_flow_file_mgr"]')
You're experiencing a known bug in jQuery v1.3.2 - jQuery is trying to interpret the image path using its absolute URL, which means the URL it's comparing actually starts with "http://...
"
You can temporarily get around this using *=
(which looks for an attribute value that contains the text "wwv_flow_file_mgr" instead of starting with it):
var $templateButtons = $('img[src*="wwv_flow_file_mgr"]').parent('a');
这篇关于jQuery选择器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!