javascript - DataTable How to prevent row click in columns containing hyperlinks -


i dealing javascript datatable clickable rows. each row when clicked forwards browser different page. column of row contains hyperlink. when hyperlin clicked don't want row click event fired or managed.

here how have implemented row click event

    $(tableid+' tbody').on( 'click', 'tr', function (e) {            window.location.href = $(this).attr('url');     }); 

when add event listener parent, event default "bubbles" downwards , attaches event children. in case setting event on tr (parent) , event bubble down , attach td (children). 1 of these td understand contains href (hyperlink) , block click event set on parent, have set event listener of event type click within function event need state event.stoppropagation() , override tr click event bubbled down.

document.addeventlistener('domcontentloaded',()=>{     //set event on parent(tr), event bubbles default downwards therefore td's inherit     document.getelementbyid('parent').addeventlistener('click',()=>window.location.href = "wherever");       //adding event listener of same type (click) blocks bubbling propogation downards     document.getelementbyid('myhyperlink').addeventlistener('click',(e)=>event.stoppropagation()); }); 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -