In previous chapter of Java Script we have learnt that what Java Script is and taken the brief introduction of what can Java Script do?

Now we are going to study more descriptively that what Java Script can do and how?

What Java Script can do?


Java Script can change the HTML element, HTML Element contents, style and attribute values. Java Script finds the HTML element by many methods. Most frequently used method is ‘getElementById()’ method.

getElementById() method


In this method Java Script find the HTML element by their ‘id’ attribute value. For example


<p id = "test"></p>
<script>
  document.getElementById('test').innerHTML = 'Hello World!';
</script>

Note : Java Script accepts both single quotes (‘ ’) and double quotes (“ “).

Java Script can Hide and Show the HTML elements


Java script can hide the HTML elements and show the elements as well by changing the element style (CSS). So we can also say that Java script can change the style of HTML elements.

This is how you can hide the HTML element.


<p id = 'test'>This paragraph is not displayed on the web page if you click below button.</p>
<button onclick = "document.getElementById('test').style.display = 'none';">Hide</button>

And this is how you can show the hidden element.


<p id = 'test'>This paragraph is not displayed on the web page if you click below button.</p>
<button onclick = "document.getElementById('test').style.display = 'block';">Show</button>

Note: You must be familiar with CSS to understand above example.

Java Script can change the value of attribute


Java script can change the value of HTML element attribute. In below example image source is change by Java Script function.


<button onclick = "document.getElementById('myImg').src = 'raincloud.png'">Rainy</button>
<img src = "cloud.png" width = '60%' id = "myImg" onclick = "cloud()">
<button onclick = "document.getElementById('myImg').src = 'cloud.png'">Sunny</button>

Java Script can Add or Remove the HTML elements


Java Script can add and remove the HTML elements. Check the example how to add the HTML element using java script.


<div id = "test">
  <p>Click the below button to create a new paragraph.</p>
</div>
 <button onclick = "createlem()">Create</button>
 
 <script>
  function createlem(){
   var para = document.createElement('p');
   var text = document.createTextNode('This is new paragraph.');
    para.appendChild(text);
   var elem = document.getElementById('test');
    elem.appendChild(para);
  }
 </script>

This is how Java Script can remove HTML element.


<div id = "elem_parent">
<p id = "elem_childe">Click the below button to remove existing paragraph.</p>
</div>
<button onclick = "delelem()">Remove</button>
 <script>
  function delelem(){
   var elem_parent = document.getElementById('elem_parent');
   var elem_childe = document.getElementById('elem_childe');
   
   elem_parent.removeChild(elem_childe);
  }
 </script>


progrramers-logo

progrramers

Hello friends! Progrramers is a tutorial site of w3 programming. If you like this tutorial site please encourages us by sharing this site links with your friends and nears & dears who want to learn web development and give us like on our Facebook page. If have any question please type in to comment box or send us message on social media sites via below given social links. Thank you, have a nice learning.

Post A Comment:

125 comments:

  1. Well, I have got the best information from here the site is fully stuffed with the knowledgeable information.
    additional reading

    ReplyDelete
  2. Hey, thanks for this great article I really like this post and I love your blog and also Check machine learning course in hyderabad at 360DIGITMG.
    360Digitmg machine learning course in hyderabad

    ReplyDelete
  3. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. 数据分析代写

    ReplyDelete
  4. When your website or blog goes live for the first time, it is exciting. That is until you realize no one but you and your. Javascript Commission Bot Review

    ReplyDelete
  5. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. I was exactly searching for. Thanks for such post and please keep it up. Great work. Howtodoninja

    ReplyDelete
  6. This is my first visit to your web journal! We are a group of volunteers and new activities in the same specialty. Website gave us helpful data to work. send a fax from an email address

    ReplyDelete
  7. I am Patrice, a front-end web developer built on the coasts of Mauritius island.
    I have 8 years of experience in the industry and the creation of websites has no secrets for me. Web development is a passion that I'm living to the fullest I have created over 300 websites in my career. "Digitalmonstr." is the nickname I use around the web. By my dedication and optimism through my work, I idealize that my clients will mark their presence on the cyberspace as giants. You will be able to beneficiate of the exceptional prices of Mauritius island which are consequently less than a traditional web agency while getting the same expertise
    (I have worked for various web agencies throughout my career)
    href="http://digitalmonstr.com

    ReplyDelete
  8. Thanks, foг ones marvelous posting! I genuinely enjoyed reading it, you miggһt Ƅe a great author. I wiⅼl made certain to booҝmark your blog and ѡill often come back sometime soon. I want to encoᥙrage yourself to continue your great job, have a nice evening!
    Web Development Course
    best web development courses
    web development classes
    web development course near me
    Web Development Training
    training on web development
    web development training program
    web development training course
    web development summer training

    ReplyDelete
  9. I don’t suppose many of websites give this kind of information. SEO Agency Calgary

    ReplyDelete
  10. Very good written article. It will be supportive to anyone who utilizes it, including me. Keep doing what you are doing – can’r wait to read more posts. web design in Switzerland

    ReplyDelete
  11. Many have a huge number of records that hold Individual Recognizing Data, PII, or insightful property that may incorporate licenses, research and unpublished electronic resources. tor links directory

    ReplyDelete
  12. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. can you send a fax from a cell phone

    ReplyDelete
  13. This blog post is really great; the standard stuff of the post is genuinely amazing.
    UX agencies

    ReplyDelete
  14. Promoting a site to increase the number of backlinks, or inbound links, is another SEO tactic.
    offpage SEO
    SEO strength
    SEO ranking

    ReplyDelete
  15. Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. Protocol

    ReplyDelete
  16. Very efficiently written information. It will be beneficial to anybody who utilizes it, including me. Keep up the good work. For sure i will check out more posts. This site seems to get a good amount of visitors.
    web developer near me

    ReplyDelete
  17. I admire this article for the well-researched content and excellent wording. I got so involved in this material that I couldn’t stop reading. I am impressed with your work and skill. Thank you so much. I will create 65 niche relevant blog comment nofollow seo backlinks

    ReplyDelete
  18. Personally I think overjoyed I discovered the blogs. Niche SEO Backlink

    ReplyDelete
  19. I really like your article. It’s evident that you have a lot knowledge on this topic. Your points are well made and relatable. Thanks for writing engaging and interesting material. backlinks

    ReplyDelete
  20. Obviously I like your web site, but you have to take a look at the spelling on quite a few of your posts. Several of them are rife with spelling problems and I find it very bothersome to inform you. Nevertheless I will surely come again again! Niche relevant OffPage Backlinks

    ReplyDelete
  21. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. download trafficize

    ReplyDelete
  22. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! Take me to another useless website

    ReplyDelete
  23. Aside from changes made to the organization site, the supposition that is regularly that the organization and, in the event that it is utilizing one, its SEO administration, has zero authority over what shows up in web crawler results.SEO Services

    ReplyDelete
  24. Thank you so much for the post you do. I like your post and all you share with us is up to date and quite informative, i would like to bookmark the page so i can come here again to read you, as you have done a wonderful job. Hummelstown Marketing

    ReplyDelete
  25. We build websites that produce impact and results. Our designers work with you until we've found a design you're happy to call your own. business to business web design

    ReplyDelete
  26. i never know the use of adobe shadow until i saw this post. thank you for this! this is very helpful. sviluppo sito ecommerce

    ReplyDelete
  27. Wow, excellent post. I'd like to draft like this too - taking time and real hard work to make a great article. This post has encouraged me to write some posts that I am going to write soon. sites like fiverr com

    ReplyDelete
  28. Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. sayapro bin checker

    ReplyDelete
  29. The web development lifecycle (WDL) is a more explicit minor departure from the overall system for building up any application development project. Webdesign Genk

    ReplyDelete
  30. For the excellent company Begin with the internet site, the customer service over the cell phone, to the detailed care they deliver in your presence
    leather jacket

    ReplyDelete

  31. Thanks for sharing this post.
    This article really useful for me and I learn a lot of things from this blog.
    I am in the process of working as a freelance mean stack developer

    ReplyDelete
  32. I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here. HTML Tutorial

    ReplyDelete
  33. This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info: pay monthly web design

    ReplyDelete
  34. I?¦m now not sure where you are getting your information, however great topic. I needs to spend some time finding out more or understanding more. Thanks for great information I used to be looking for this info for my mission. visit this web-site

    ReplyDelete
  35. Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts. SEO Service Provider

    ReplyDelete
  36. The web hosting companies provide a share of disk space and available bandwidth to a customer for a monthly fee. Once the customer is signed up, they can upload files to their personal space on the web server and the information is then viewable to anyone interested on the Internet. web hosting

    ReplyDelete
  37. At the point when you need reasonable web facilitating for your private venture. ESIT web facilitating has a lot of brilliant highlights to bring to the table. https://zenradius.com

    ReplyDelete
  38. Its for these reasons it happens to be improved that anyone can helpful test earlier than building. It will be possible to write more piece of writing like this. Graphics Design

    ReplyDelete
  39. Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading. hire freelance python developers

    ReplyDelete
  40. On the off chance that your planner comprehends web optimization and plans for web based promoting during the plan stage your webpage will see huge profits from your interest in method of traffic and client transformations. Web Design Manchester

    ReplyDelete
  41. I simply want to tell you that I am new to weblog and definitely liked this blog site. Very likely I’m going to bookmark your blog . You absolutely have wonderful stories. Cheers for sharing with us your blog. homepage

    ReplyDelete
  42. I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work. Pyramid Analytics

    ReplyDelete
  43. I am incapable of reading articles online very often, but I’m happy I did today. It is very well written, and your points are well-expressed. I request you warmly, please, don’t ever stop writing. dofollow blog comment

    ReplyDelete
  44. This programming language is very helpful for developers and through this, they can make different softwares and earn a lot of money. You should learn JavaScript and make your future bright. Coursework writing service.

    ReplyDelete
  45. Great articles and great layout. Your blog post deserves all of the positive feedback it’s been getting. https://hostinglelo.in/

    ReplyDelete
  46. There's Amazon Drive, which offers limitless record stockpiling for just $59.99 dollars each year. As of late, they additionally procured the real time site jerk, the biggest computer game live stream site there is giving Amazon portion of the overall industry in the streaming and e-sports ventures. web development services in pakistan

    ReplyDelete
  47. I cannot wait to dig deep and kickoff utilizing resources that I received from you. Your exuberance is refreshing. https://hostinglelo.in/

    ReplyDelete
  48. I think this is an informative post and it is very beneficial and knowledgeable. Therefore, I would like to thank you for the endeavors that you have made in writing this article. All the content is absolutely well-researched. Thanks... dark0de market

    ReplyDelete
  49. It is quite beneficial, although think about the facts when it reaches this target. seo

    ReplyDelete
  50. You will actually want to see whether there are any objections in regards to the help that the agency gives. webagenturessen.de

    ReplyDelete
  51. Beaver says I other than have such compensation, you can pulverize my profile here: dark0de market link

    ReplyDelete
  52. Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. slot online terpercaya

    ReplyDelete
  53. Luckily, we have our own web server here at Digital Spiral Web Design so we can do all of the facilitating ourselves.Web Development Agency

    ReplyDelete
  54. Anyone looking to exploit SEO web design service can choose a leading SEO company that offers excellent professional services at affordable prices. Most of the SEO firms have a team of web designers, innovative graphic designers, developers and search engine optimization consultants to provide a full range of web design services for your Internet business creation, promotion and support. Web Design Company Toronto

    ReplyDelete
  55. Most importantly you should search out the video destinations that will supply you the assets to make your own video. It is because of the way that the site must be extraordinary. check out my patreon

    ReplyDelete
  56. I'm glad to see the great detail here!. agencia de design

    ReplyDelete
  57. I really loved reading your blog. It was very well authored and easy to understand. Unlike other blogs I have read which are really not that good.Thanks alot! agencia de design

    ReplyDelete
  58. Thanks for providing recent updates regarding the concern, I look forward to read more. mobile app development sydney

    ReplyDelete
  59. Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. Black satta king

    ReplyDelete
  60. Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. Disawar satta result

    ReplyDelete
  61. Nice post. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part Cheap Verified Perfect Money Account

    ReplyDelete
  62. I have a hard time describing my thoughts on content, but I really felt I should here. Your article is really great. I like the way you wrote this information https://couchtuner.quest

    ReplyDelete
  63. I am impressed. I don't think Ive met anyone who knows as much about this subject as you do. You are truly well informed and very intelligent. You wrote something that people could understand and made the subject intriguing for everyone. Really, great blog you have got here https://couchtuner.rest

    ReplyDelete
  64. I found that site very usefull and this survey is very cirious, I ' ve never seen a blog that demand a survey for this actions, very curious https://soap2day.shop

    ReplyDelete
  65. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. https://soaptoday.website

    ReplyDelete
  66. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. https://solarmovies.space

    ReplyDelete
  67. Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive https://soaptoday.space

    ReplyDelete
  68. Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive! https://1soaptoday.site

    ReplyDelete
  69. Thank you so much as you have been willing to share information with us. We will forever admire all you have done here because you have made my work as easy as ABC https://putlockers9.live

    ReplyDelete
  70. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
    https://watchcouchtuner.website

    ReplyDelete
  71. Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive! https://newputlocker.website

    ReplyDelete
  72. Remarkable article, it is particularly useful! I quietly began in this, and I'm becoming more acquainted with it better! Delights, keep doing more and extra impressive https://watchcouchtuner.space

    ReplyDelete
  73. The Web lets us market our services and products any place in the Earth, but to be able to actually earn a sale, we have to set a relationship that generates a sufficient amount of trust, confidence, loyalty and passion. Environmentally-friendly web hosting is getting more and more popular for business web sites appearing to implement an eco-policy. web design dubai

    ReplyDelete
  74. Hi everybody thanks a lot for your support and love day by day progrramers is doing well and approach over the web is getting larger. So once again thank you very much.

    ReplyDelete
  75. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. JAV TURISTINĖ VIZA

    ReplyDelete
  76. You know your projects stand out of the herd. There is something special about them. It seems to me all of them are really brilliant! URGENT INDIA VISA

    ReplyDelete
  77. You there, this is really good post here. Thanks for taking the time to post such valuable information. Quality content is what always gets the visitors coming. 토토사이트

    ReplyDelete
  78. This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. Turkey Visa Eligibility

    ReplyDelete
  79. I am always searching online for storys that can accommodate me. There is a multiple to understand about this. I feel you made a few salubrious points in Attributes moreover. Detain busy, awesome career! Ka Palapala Noi Visa ʻo Kanada

    ReplyDelete
  80. Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. indian visa for tourists

    ReplyDelete
  81. Can I just say that of a relief to locate someone who actually knows what theyre preaching about online. You definitely learn how to bring a problem to light and work out it important. The best way to ought to ought to see this and appreciate this side from the story. I cant believe youre less well-liked as you certainly possess the gift. 토토커뮤니티

    ReplyDelete
  82. I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business. ibmseo

    ReplyDelete
  83. I read that Post and got it fine and informative. 토토커뮤니티

    ReplyDelete
  84. I also wrote an article on a similar subject will find it at write what you think. 꽁머니사이트

    ReplyDelete
  85. Friend, this web site might be fabolous, i just like it. IfB Verlag Deutsche Sprache

    ReplyDelete
  86. Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading. 먹튀검증

    ReplyDelete
  87. I should say only that its awesome! The blog is informational and always produce amazing things. 먹튀검증사이트

    ReplyDelete
  88. Thank you for some other informative website. The place else may just I get that kind of information written in such a perfect method? I have a venture that I am simply now running on, and I’ve been at the glance out for such info. wild hemp hempettes

    ReplyDelete
  89. I use basically superior fabrics : you will discover these products by: 먹튀검증사이트

    ReplyDelete
  90. Make the most of mainly premium substances - you will find him or her for: beylikduzu eskort

    ReplyDelete
  91. Here you will learn what is important, it gives you a link to an interesting web page: 스포츠중계

    ReplyDelete
  92. Thanks, that was a really cool read! 토토114

    ReplyDelete
  93. On this page, you can read my interests, write something special. pggame

    ReplyDelete
  94. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work... Centro de solicitud de visados ​​de Turquía

    ReplyDelete
  95. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with extra information? It is extremely helpful for me. Web Design Melbourne

    ReplyDelete
  96. Actually I read it yesterday but I had some thoughts about it and today I wanted to read it again because it is very well written. 토토커뮤니티

    ReplyDelete
  97. Thanks For sharing this Superb article.I use this Article to show my assignment in college.it is useful For me Great Work. Centro de solicitud de visados ​​de Turquía

    ReplyDelete
  98. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. https://oisjrgiks.com

    ReplyDelete
  99. On this website, you will see this shape, I highly recommend you learn this review. 먹튀검증

    ReplyDelete
  100. On that website page, you'll see your description, why not read through this. 토토사이트

    ReplyDelete
  101. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. 먹튀검증

    ReplyDelete
  102. Interesting topic for a blog. I have been searching the Internet for fun and came upon your website. Fabulous post. Thanks a ton for sharing your knowledge! It is great to see that some people still put in an effort into managing their websites. I'll be sure to check back again real soon. rims for sale

    ReplyDelete
  103. Thank you again for all the knowledge you distribute,Good post. I was very interested in the article, it's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing! Regards, 貸款

    ReplyDelete
  104. I think this is an informative post and it is very useful and knowledgeable. therefore, I would like to thank you for the efforts you have made in writing this article. 借錢

    ReplyDelete
  105. I have read your blog it is very helpful for me. I want to say thanks to you. I have bookmark your site for future updates. 買房子

    ReplyDelete
  106. Thanks for taking the time to discuss this, I feel strongly about it and love learning more on this topic. If possible, as you gain expertise, would you mind updating your blog with extra information? It is extremely helpful for me. 먹튀검증

    ReplyDelete
  107. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. 토토사이트

    ReplyDelete
  108. Hey There. I found your blog using msn. This is a very well written article. I’ll be sure to bookmark it and come back to read more of your useful info. Thanks for the post. I’ll definitely return. https://Starvegasvip.com

    ReplyDelete
  109. Keep up the good work; I read few posts on this website, including I consider that your blog is fascinating and has sets of the fantastic piece of information. Thanks for your valuable efforts. https://gostream.today

    ReplyDelete
  110. Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our. https://moviecrumbs.site

    ReplyDelete
  111. Your blog is too much amazing. I have found with ease what I was looking. Moreover, the content quality is awesome. Thanks for the nudge! https://goojara.today

    ReplyDelete
  112. Your blog is too much amazing. I have found with ease what I was looking. Moreover, the content quality is awesome. Thanks for the nudge! https://pagalmovies.life

    ReplyDelete
  113. Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome! https://lookmovies.media

    ReplyDelete
  114. You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us to read this... https://afdah.digital

    ReplyDelete
  115. Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome! https://afdah.productions

    ReplyDelete
  116. Excellent website! I adore how it is easy on my eyes it is. I am questioning how I might be notified whenever a new post has been made. Looking for more new updates. Have a great day! https://playdesi.site

    ReplyDelete
  117. The best article I came across a number of years, write something about it on this page. SEO Package

    ReplyDelete
  118. Great survey, I'm sure you're getting a great response.
    https://watchserieshd.media

    ReplyDelete
  119. Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you.
    https://watchserieshd.space

    ReplyDelete
  120. I understand this column. I realize You put a many of struggle to found this story. I admire your process. 토토사이트

    ReplyDelete