How to use HTML5 to make your CSS look like brainfuck
mathiasbynens.be
mathiasbynens.be
Funnily enough, I just registered here, trying to use my first name Øystein, and what did ol' hackernews tell me? "Usernames can only contain letters, digits, dashes and underscores"
(In case you don't recognize it php will automatically turns names that look like that into an array.)
Or if you are trying to name fields from a multi dimensional array. Say name['foo']['bar'] - you would name the id name_foo_bar
Simple enough, except when you also have an array: name['foo_bar'] - which looks identical to the first one.
Now that you can use other characters besides _ to separate the fields that helps a ton.
PHP does not have access to IDs of HTML elements. Or did you mean something else?
When a form containing <input type="text" name="foo" value="bar"> is submitted, $_POST['foo'] === 'bar' in PHP. (And it works similarly for other server-side programming languages.)
<input type="text" name="foo[bar][]" value="yaw" />
will result in: $_POST['foo'][0] === "yaw";
In other words you can have a form create multidimensional arrays.For example, you can do something like this:
<a href="#hello" class="{name:'George'}" />
and then in jQuery you can retrieve the metadata like so:
$('a').metadata('name'); // returns "George"
Its incredibly useful for associating metadata with DOM elements without breaking the HTML's validity.
(I say this as someone who used to use random HTML attributes.)
http://dev.w3.org/html5/spec/elements.html#embedding-custom-...
$('.' + div.attr('id')).each(function() {
$('body').append($(this); // Moving elements
});
Now imagine that I give the id attribute the following id: 'nada,<script src="evil.js"></script>'I suppose this is a bit contrived but still fun.
FYI, the `.append` line is missing a closing `)`. Also, you probably don’t want to use `$(this)` in that case, you could just use `this`.
As for the escaping, how would we do that? jQuery specifically allows something like $('<div/>'). As far as I know, it does not have an escape character to prevent that. My point is that that character would need to be added to jQuery and other libraries that have the same function for fetching DOM elements and creating them. Obviously, in raw JavaScript this is not a problem since there it's two different methods (document.getElementById and document.createElement).
var str = "Hello \"world\", how\\are you";
But once you have your string composed, jQuery does not as far as I know have a way to escape characters like < and >.A: No, but if you want, I can write you some CSS that looks just like it!