LCDesign Cambridge
LCDesign Cambridge

Reputation: 144

jquery selector as a custom attribute

I am Using jquery how can I trigger an alert when mouseover the element with the data-code=GB atribute?

I tried this with no luck...

  $(".jvectormap-container path[data-code='GB']").mouseover(function(){
     alert('test');
  });

Thank you

Upvotes: 1

Views: 269

Answers (4)

bjornd
bjornd

Reputation: 22943

Why not to use standard parameter of the jVectorMap onRegionOver? Your code won't work in IE, because there are no path element in IE, it uses shape instead.

Upvotes: 1

Sushanth --
Sushanth --

Reputation: 55740

Try this

$(function() {
    $(".jvectormap-container").filter("path[data-code='GB']").on('mouseover',function(){
        alert('test');
    });
});

Upvotes: 0

Ravi Kumar
Ravi Kumar

Reputation: 1402

With slight modification, its working for me. I added -

<head>
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
 <script>
   $(document).ready(function(){
     $('.jvectormap-container path[data-code="GB"]').bind('mouseover', function(){
       alert('test');
     });
   });
  </script>
</head>

Working copy is here: http://jsbin.com/uwatiz/5/edit

Upvotes: 1

d1pr3d
d1pr3d

Reputation: 76

You have the path inside a div. Which is something wrong. With proper usage of path your js code works fine.

<svg xmlns="http://www.w3.org/2000/svg" version="1.1" class="jvectormap-container">
 <path d="M150 0 L75 200 L225 200 Z" data-code='GB' />
</svg>

Upvotes: 0

Related Questions