2012-02-21 57 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