0

i have a situation in my page i don't have any clue other than this 2 clue to target

<div itemscope>
 some <html>
........
</div>

how can i target div having itemscope i,e <div itemscope>

suppose i have structure like this

    <div itemscope>
      <a hrfe="http://www.a.com">a.com</a>
    </div>

    <div itemscope type="tang">
      <a hrfe="http://www.b.com">b.com</a>
    </div>

    <div>
      <a hrfe="http://www.c.com">c.com</a>
    </div>


    <div>
      <a hrfe="http://www.d.com">d.com</a>
    </div>

PLEASE SUGGEST ME WHAT THIS KIND OF SELECTOR IS CALLED SO THAT I CAN SEARCH IT ON STACKOVERFLOW

var allDivWith_itemscope = $('div[i don"t know what else]');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<div itemscope>
  <a hrfe="http://www.a.com">a.com</a>
</div>
<div itemscope type="tang">
  <a hrfe="http://www.b.com">b.com</a>
</div>

<div>
  <a hrfe="http://www.c.com">c.com</a>
</div>


<div>
  <a hrfe="http://www.d.com">d.com</a>
</div>

1 Answers1

1

Well there are two things i want to mention:

  1. You have a typo with href attribute.
  2. You should use data-* prefix for custom attributes.

So, on basis of these you can change to this:

<div data-itemscope>

Now in js/jquery/css you can do this:

// css
div[data-itemscope]{
  properties:values;
}

// javascript
document.querySelector('div[data-itemscope]')

//jquery
$('div[data-itemscope]') 
Jai
  • 74,255
  • 12
  • 74
  • 103
  • it is a dynamic `content` obtained from our client , they do have `div` as exactly as this `
    ` they did it to avoid `content scrapping`
    –  Dec 21 '16 at 08:00