JQuery получить не стоять HTML-теги - PullRequest
1 голос
/ 21 февраля 2012

Возможно ли это?

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>​

Ответы [ 3 ]

2 голосов
/ 21 февраля 2012

Да, это возможно.

Ваш пример кода не работал, так как вы пропустили закрывающую скобку.

jsFiddle .

2 голосов
/ 21 февраля 2012

Вы не закрыли свое заявление if

http://jsfiddle.net/6RNQZ/

2 голосов
/ 21 февраля 2012

Вам не хватает скобки.

http://jsfiddle.net/bQLPt/5/

if ($('svg image[href="Images/pin_icon_red_unit.png"]').length) {
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...