Check if Div with specific Class exists in the page

后端 未结 3 1868
闹比i
闹比i 2021-01-27 20:09

I\'m trying to modify an existing webpage by inserting my own Javascript file in it. I\'m setting a background Image for this webpage by inserting a new Div through my Javascrip

3条回答
  •  失恋的感觉
    2021-01-27 21:03

    You'd have to loop through all of the

    elements on the page, until one matches the className you are looking for. Something like:

    var div = document.getElementsByTagName('div');
    for(i=0; i

提交回复
热议问题