Search code examples
javascriptjqueryfirefoxgreasemonkey

trigger click on div style which don't contain id


trigger click on div if viewed hide it..

DIV

`<div style="background-color: transparent;
background: -moz-linear-gradient(center top , #10bece 0%, #0c8d99 100%);
background: -webkit-linear-gradient(#10bece, #0c8d99);
background-repeat: repeat;
background-attachment: scroll;
background-position: 0% 0%;
background-clip: border-box;
background-origin: padding-box;
background-size: auto auto;text-overflow:hidden;overflow:hidden;white-space:nowrap;padding:2px;padding-left:3px;padding-right:3px;width:190px;border-radius:3px 3px 0 0;"><a href="./view.php?i=4435" target="_blank" style="text-overflow: ellipsis;overflow: hidden;white-space: nowrap;font-weight: normal;font-size: 13px;height: 17px;line-height: 17px;color: #FFF;">Join ooo</a></div>`

HTML

<table width="100%"><tbody><tr><td style="font-size:11px;color:#666;padding:1px;border-top:1px dashed green;padding-top:3px;"><td style="width:60%">&<b>0.0~0.02</b></td><td align="right"></td></tr></tbody></table></td>

code sample

$('.style="color:#666').click();

Solution

  • What you can do is something tricky with filter()

    $('[style]').filter(function() {
      $(this).attr('style').indexOf('color:#666') > -1;
    }).click();
    

    or with attribute contains selector

    $('[style*="color:#666"]').click();
    

    FYI : If you are searching for td then use $('td[style... or in case it's div then use $('div[style... otherwise it may select other element with same inline style property.