2012-02-21 58 views
1

这可能吗?JQuery获得非站点html标记

http://jsfiddle.net/bQLPt/4/

if ($('svg image[href="Images/pin_icon_red_unit.png"]').length { 

alert("red");  

} 



<svg id="OpenLayers.Layer.Vector_179_svgRoot" width="1556" height="556" viewBox="0 0 1556 556"><g id="OpenLayers.Layer.Vector_179_root" style="display: block; visibility: visible; " transform=""><g id="OpenLayers.Layer.Vector_179_vroot"><image id="OpenLayers.Geometry.Point_238" cx="778" cy="278" r="1" preserveAspectRatio="none" x="758" y="258" width="40" height="40" href="Images/pin_icon_red_unit.png" style="opacity: 1" fill="#000000" fill-opacity="1" stroke="#000000" stroke-opacity="1" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" pointer-events="visiblePainted"></image><image id="OpenLayers.Geometry.Point_240" cx="906" cy="406" r="1" preserveAspectRatio="none" x="886" y="386" width="40" height="40" href="Images/pin_icon_red_unit.png" style="opacity: 1" fill="#000000" fill-opacity="1" stroke="#000000" stroke-opacity="1" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" pointer-events="visiblePainted"></image><image id="OpenLayers.Geometry.Point_242" cx="1034" cy="534" r="1" preserveAspectRatio="none" x="1014" y="514" width="40" height="40" href="Images/pin_icon_red_unit.png" style="opacity: 1" fill="#000000" fill-opacity="1" stroke="#000000" stroke-opacity="1" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="none" pointer-events="visiblePainted"></image></g><g id="OpenLayers.Layer.Vector_179_troot"></g></g></svg>​ 
+0

你可以是一个更加清楚一点,以你想做的事,和清理你的代码是什么,因此至少没有语法错误? – GoldenNewby 2012-02-21 01:09:20

回答

2

是的,这是可能的。

您的示例代码不起作用,因为您错过了右括号。

jsFiddle