Html额外属性作为请求调用

My Html links has extra attributes, like:

<a cat-data="175" rt-data="154" href="index.php?view=item"></a>
<a cat-data="775" rt-data="134" href="index.php?view=item"></a>
<a cat-data="575" rt-data="174" href="index.php?view=item"></a>

In this code is to see: cat-data="" and rt-data=""

If i click on this link and go to next page, can i request this data? cat-data="" and rt-data=""

Adding arbitrary attributes to an <a> element will not transfer them as part of the URL. So no, at least not as it stands.

You can encode them in the URL in the first place:

href="index.php?view=item&amp;rt=174&amp;cat=575"

and they will be accessible through $_GET.

You could also use JavaScript to modify the href attribute based on the other attributes, but that is needlessly complicated and dependant on JavaScript, so it is not recommended.


Note that adding arbitrary attributes to an element will make your HTML invalid and is not recommended. HTML 5 allows custom attributes if the name starts with data-, which might be what you are trying to use here, but you are using data as a suffix when it must be a prefix.

the data attribute uses for jquery and javascript and you can't have them in the next page, or on servers side, you can add the data to the url and then get them as get or post, you can also store data on cookies and get the cookies on the next page

please use the next url : href="index.php?view=item&cat-data=175&rt-data=154