JQuery: Novice to Ninja- P5:No matter what kind of ninja you are—a cooking ninja, a corporate lawyer ninja, or an actual ninja ninja—virtuosity lies in first mastering the basic tools of the trade. Once conquered, it’s then up to the full-fledged ninja to apply that knowledge in creative and inventive ways. | Selecting Decorating and Enhancing 37 There might be more people than you think browsing the Web without JavaScript users on very old computers or limited devices like mobile phones people with visual impairments who require screen readers to use the Web and those who worry that JavaScript is an unnecessary security risk and so choose to disable it. Depending on your site s demographic anywhere between 5 and 10 of your users might be browsing without JavaScript capabilities and nobody wants to alienate 10 of their customers The solution is to provide an acceptable experience to these users and beef it up for everyone else. This practice is known as progressive enhancement. For our disclaimer functionality we might settle on this compromise we want the disclaimer to be visible to all users so we place it in our HTML. Then we add the ability to hide it for users with JavaScript. That said we d prefer to avoid displaying the show hide button to users who ll be unable to make use of it. One way of accomplishing this might be to hide our button with CSS and only show it via a jQuery css statement. The problem with this trick is that it will fail if the user s browser also lacks support for CSS. What we d really like to do is add the button to the page via jQuery that way only users with JavaScript will see the button at all. Perfect Adding New Elements So far we ve seen the jQuery function used for selecting but it does have another function of equal importance creating new elements. In fact any valid HTML string you put inside the jQuery function will be created and made ready for you to stick on the page. Here s how we might create a simple paragraph element p A new paragraph p jQuery performs several useful actions when you write this code it parses the HTML into a DOM fragment and selects it just as an ordinary jQuery selector does. That means it s instantly ready for further jQuery processing. For example to add a class to our newly created element we can simply .