最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to disable an onclick option in span? - Stack Overflow

programmeradmin9浏览0评论

I have this

 <span class="ui-icon ui-icon-info"  id="icon" runat="server"  ></span>

I dont use onclick but my icon is clickable (maybe because the jquery-ui class...) I need to disable the onclick completely.

Is there a way to do it?

I have this

 <span class="ui-icon ui-icon-info"  id="icon" runat="server"  ></span>

I dont use onclick but my icon is clickable (maybe because the jquery-ui class...) I need to disable the onclick completely.

Is there a way to do it?

Share Improve this question asked Jan 26, 2014 at 17:56 user2560521user2560521 4762 gold badges6 silver badges18 bronze badges 4
  • you want the cursor to be like same or what ? – Kawinesh S K Commented Jan 26, 2014 at 18:14
  • i need the hover from the jquery ui plugin to be diseable ( i think..) – user2560521 Commented Jan 26, 2014 at 18:19
  • can you create a fiddle ? – Kawinesh S K Commented Jan 26, 2014 at 18:23
  • i have created i cant see any hover or click changes occurrence here jsfiddle.net/mXjHJ/768 – Kawinesh S K Commented Jan 26, 2014 at 18:26
Add a comment  | 

4 Answers 4

Reset to default 6

You can try:

jQuery off() to off the onclick event for specific span.

Use:

jQuery( "span#icon" ).off("click");

Check w3schools tutorial for this

Or, You can try:

jQuery( "span#icon" ).css("cursor","default");

I guess the clicking on the span does not fire any event if not specified, means this is more a design issue

If there is a hand-cursor coming up as soon as you hover you can spcecify this by the cursor attribute in css:

.someclass {
   cursor: default
}

Another possibility if there is some event fireing as seen here: Use CSS to make a span not clickable

<span class='unclickable' onclick='return false;'>description<br></span>

i am new in stackoverflow. i am trying to add my code here but i am failed for that reason i just added picture here with my Html code and script are

For a clickable span: html:

<span class="clickable-span">View</span>

css:

.clickable-span {
    color: darkcyan;
    text-decoration-line: underline;
}
.clickable-span:hover {
    cursor: pointer;
}

For a Unclickable span: html:

<span class="unclickable-span">View</span>

css:

.unclickable-span{
    color: cyan;   
    cursor: default;
}
发布评论

评论列表(0)

  1. 暂无评论