blsn
blsn

Reputation: 1093

Description text to appear by cursor pointer

Probably this is easy, but I cannot get it work:

Using the following title attribute, I can display a description text on the defined clickable area:

$("#myElement").attr('title', ‘description text’);

Is it possible to do the above but instead of the title attribute to use the "finger" cursor?

Maybe like as follows:

$("myElement").cursor("pointer")

Upvotes: 0

Views: 3848

Answers (4)

   $( ".boxClose" ).text( "Title" ).css( 'cursor', 'pointer' );
   $("#myElement").append($(".boxClose"));

 <style>
 .boxClose{
  position:absolute;
  top:0px;
  width:100%;
  height:10px;
 }
 </style>

Use append to add text and change it to cursor .. jquery awesome ..

Upvotes: 1

Justin Bicknell
Justin Bicknell

Reputation: 4808

Yes but I would recommend css over js:

#myelement {
    cursor:pointer
}

Not sure if you are looking for the most condensed way to do both of these in js, if so then this would be pretty close:

$('#myElement').title('text here').css('cursor','pointer');

Upvotes: 1

Explosion Pills
Explosion Pills

Reputation: 191749

I don't understand what the title and cursor have to do with each other, but you can change styles in jQuery using:

$("myElement").css('cursor', 'pointer')

Note that there is an important difference between HTML attributes and styles. title is an attribute and is changed via .attr.

Upvotes: 1

dimusic
dimusic

Reputation: 4133

If you really need to change css properties of the element with javascript, you can use .css() function in jquery

$("myElement").css("cursor", "pointer")

Upvotes: 0

Related Questions