Use CSS to make a span not clickable

后端 未结 7 2208
无人及你
无人及你 2020-12-08 03:55

    
    
    
        
      
7条回答
  •  Happy的楠姐
    2020-12-08 04:20

    In response to piemesons rant against jQuery, a Vanilla JavaScript(TM) solution (tested on FF and IE):

    Put this in a script tag after your markup is loaded (right before the close of the body tag) and you'll get a similar effect to the jQuery example.

    a = document.getElementsByTagName('a');
    for (var i = 0; i < a.length;i++) {
      a[i].getElementsByTagName('span')[1].onclick = function() { return false;};
    }
    

    This will disable the click on every 2nd span inside of an a tag. You could also check the innerHTML of each span for "description", or set an attribute or class and check that.

提交回复
热议问题