最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Find html Footer tag using javascript - Stack Overflow

programmeradmin3浏览0评论

I have on html file in that there is one footer tag like this <footer data-role="footer" data-theme="b"> <h4 > My Web Site </h4> </footer> i want to hide this footer using javascript please help me out.

I have on html file in that there is one footer tag like this <footer data-role="footer" data-theme="b"> <h4 > My Web Site </h4> </footer> i want to hide this footer using javascript please help me out.

Share Improve this question asked Sep 24, 2012 at 5:41 Nishit PatelNishit Patel 1491 gold badge2 silver badges13 bronze badges 2
  • Please say what you've tried next time, perhaps including what you've searched for. – jmdeldin Commented Sep 24, 2012 at 5:49
  • okay thank you for you suggestion next time i won't do this. – Nishit Patel Commented Sep 24, 2012 at 5:56
Add a ment  | 

2 Answers 2

Reset to default 13

You can use document.querySelector or document.getElementsByTagName.

document.querySelector('footer').style = 'display: none'

You could assign this footer an id and then use the document.getElementById to retrieve it and hide it:

document.getElementById('footer_id').style = 'display: none;';

As an alternative you could use the document.getElementsByTagName function if you cannot modify the markup.

var footers = document.getElementsByTagName('footer');
footers[0].style = 'display: none;';

Obviously if you have more than one <footer> elements in your markup the getElementsByTagName function will return all of them and you will have to pick the right element from the array.

发布评论

评论列表(0)

  1. 暂无评论