Have to create label with JavaScript

 If I dynamically create an 'input' tag with JavaScript then I seem to have to dynamically create the 'label' tag too.


If the 'label' tag is in the static HTML without the 'input' tag then the W3C HTML validator says the 'for' attribute of the 'label' tag points to an 'input' tag that does not exist.


I dynamically create the 'input' tag to avoid the browser asking me to confirm that I want to leave the page when I have entered something in the 'input' tag. The 'input' tag is not part of a form that is submitted.


Also I have to dynamically create an 'img' tag with JavaScript when I set the 'src' attribute with JavaScript.


If the 'img' tag is in the static HTML without a 'src' tag then the W3C HTML validator says there is an error.


I dynamically set the 'src' attribute because I am showing a carousel of images with JavaScript.


I am worried that Google's search will see my page a bit like how the validator does. I add the 'input' tag after a delay after the page loads. I do this to speed up the page load.


There are more tips at: bbingo.xyz/techtips/

Comments

Popular posts from this blog

webkit-tap-highlight-color in CSS

Steve Jobs quotes