Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curly brackets in HTML

Tags:

html

I stumbled upon this code:

<a href="#" class="text1"{text2}>...</a>

What does the {text2} do? Later on, this HTML is replaced with:

<a href="#" class="text1" {text2} style>...</a>

Is there a way I can retrieve the text2 value with jQuery?


2 Answers

In some cases that code is input in, so scripts can actually easily identify a the line. Or in some cases can be an indicator for a database to retrieve and store data once it has been pulled.

Or it could be invalid markup, doubtful if the person knows what they are doing.

But without any other information or variables it is hard to say. But the most common is access for scripts within Php, Javascript, and even C#. Cause they can parse the HTML document and manipulate it. If those braces are used, and it is incorrectly it will cause a parse error.

Hopefully that sort of clarifies it.


Update:

Yes, jQuery can find it. It is a form of Javascript. You could implement something such as:

$(function() {
    var foundString = $('*:contains("{text1}")');
});

There is a vast amount of data that addresses this for more detail.

like image 180
Greg Avatar answered Sep 15 '25 21:09

Greg


It does nothing in HTML. It's actually invalid markup. Looks like maybe you have a template system that finds and replaces that before it gets rendered to the browser.

like image 34
Glitches Avatar answered Sep 15 '25 20:09

Glitches