Storing arbitrary info in HTML tags for JavaScript?
with the introduction of html5, you can use attributes that start with data-, and they’ll still validate. <input type=”text” name=”username” data-parentTab=”tab1″ value=”non-default”>
with the introduction of html5, you can use attributes that start with data-, and they’ll still validate. <input type=”text” name=”username” data-parentTab=”tab1″ value=”non-default”>
Here’s some simple, naive code to do this that may well do the job for your use case. It does not take into account any text that may be made invisible (either by CSS or by being inside a or element, for example) and may have browser discrepancies (IE versus everything else) with line breaks, … Read more
Update now, which you can find on the jQuery doc site: .load() It DOES strip tags only if you call load with a specific suffixed selector.. Script Execution When calling .load() using a URL without a suffixed selector expression, the content is passed to .html() prior to scripts being removed. This executes the script blocks … Read more
<?php echo ‘<div> <h3><a href=”#”>First</a></h3> <div>Lorem ipsum dolor sit amet.</div> </div> <div>’; ?> Just put it in single quotes.
Telling people to add <SCRIPT> only in the head sounds like a reasonable thing to do, but as others have said there are many reasons why this isn’t recommended or even practical – mainly speed and the way that HTML pages are generated dynamically. This is what the HTML 4 spec says : The SCRIPT … Read more
When using <button> always specify the type, since browsers default to different types. This will work consistently across all browser: <button type=”submit”>…</button> <button type=”button”>…</button> This way you gain all of <button>‘s goodness, no downsides.
The specification (section 3.1 Start-tags, end-tags, and empty-element tags) says that there is no white space between the ‘<‘ and the tag name, between ‘</’ and the tag name, or inside ‘/>’. You can add white space after the tag name, though: <foo > </foo > <bar />
git tag –contains <commit>
Edit: I’m tired and not thinking. You can just use the native innerHTML method instead of .html(): $(‘#feedback-‘ + idfeedback)[0].innerHTML = x; Original answer: My hunch is that the answer you linked doesn’t work for you because the included scripts are called with a src attribute rather than script content between the <script> and </script> … Read more
There is no consensus on best practice, and according to the author of the spec, Ian Hickson, it does not matter.