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:

97 comments:

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

    ReplyDelete
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. I don’t suppose many of websites give this kind of information. SEO Agency Calgary

    ReplyDelete
  8. 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
  9. 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
  10. 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
  11. This blog post is really great; the standard stuff of the post is genuinely amazing.
    UX agencies

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

    ReplyDelete
  13. 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
  14. 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
  15. Personally I think overjoyed I discovered the blogs. Niche SEO Backlink

    ReplyDelete
  16. 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
  17. 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
  18. 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
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
  26. 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

  27. 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
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. 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
  36. 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
  37. 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
  38. 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
  39. 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
  40. 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
  41. Great articles and great layout. Your blog post deserves all of the positive feedback it’s been getting. https://hostinglelo.in/

    ReplyDelete
  42. 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
  43. I cannot wait to dig deep and kickoff utilizing resources that I received from you. Your exuberance is refreshing. https://hostinglelo.in/

    ReplyDelete
  44. 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
  45. You will actually want to see whether there are any objections in regards to the help that the agency gives. webagenturessen.de

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

    ReplyDelete
  47. 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
  48. 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
  49. 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
  50. 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
  51. I'm glad to see the great detail here!. agencia de design

    ReplyDelete
  52. 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
  53. Thanks for providing recent updates regarding the concern, I look forward to read more. mobile app development sydney

    ReplyDelete
  54. 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
  55. 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
  56. 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
  57. 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
  58. 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
  59. Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking.
    https://watchcouchtuner.website

    ReplyDelete
  60. 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
  61. 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
  62. 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
  63. 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
  64. 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
  65. 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
  66. 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
  67. 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
  68. 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
  69. I read that Post and got it fine and informative. 토토커뮤니티

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

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

    ReplyDelete
  72. 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
  73. 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
  74. I use basically superior fabrics : you will discover these products by: 먹튀검증사이트

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

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

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

    ReplyDelete
  78. 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
  79. 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
  80. 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
  81. 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
  82. On this website, you will see this shape, I highly recommend you learn this review. 먹튀검증

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

    ReplyDelete
  84. 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
  85. 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
  86. 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
  87. 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
  88. 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
  89. Thanks for the blog loaded with so many information. Stopping by your blog helped me to get what I was looking for. 토토사이트

    ReplyDelete
  90. Lorsqu'il s'agit de créer une entreprise, il y a beaucoup de choses à prendre en compte. Qu'il s'agisse de trouver le bon emplacement ou de recruter les bons employés, la liste des tâches peut sembler interminable. Pour de nombreux entrepreneurs, l'un des défis les plus redoutables est simplement de savoir par où commencer. Si vous envisagez de créer une entreprise de nettoyage, le forum startupo est l'endroit idéal pour obtenir des conseils et des idées de professionnels. Avec plus de 566 questions et réponses, c'est une véritable mine d'informations. Que vous cherchiez des astuces de marketing ou des conseils pour choisir le bon équipement, vous êtes sûr de trouver ce que vous cherchez. Si vous êtes prêt à vous lancer dans l'entrepreneuriat, n'hésitez pas à consulter le forum startupo. https://startupo.fr/question/563/combien_d'argent_pour_monter_son_entreprise/

    ReplyDelete
  91. i love it this is very useful information,and do have know about stretch flexibility

    ReplyDelete
  92. thanks for this usefull article, waiting for this article like this again. family

    ReplyDelete
  93. Ficode is a full-fledged bespoke web development company in UK assisting companies to turn their business online. Hire our web developers uk today!

    ReplyDelete