wilson1000
asked on
jQuery Short hand Tag?
Hi Experts,
I can't seem to find any information regarding the type of tag used in the following code snippet.
Would someone be kind enough to explain the syntax please?
Many thanks
I can't seem to find any information regarding the type of tag used in the following code snippet.
Would someone be kind enough to explain the syntax please?
Many thanks
$("<a/>").html("<span class=\"verdana\">« </span>Prev")
Insert a span in the innerHTML of an anchor that has no content already
However it does not seem to work
Here are all selectors
http://api.jquery.com/category/selectors/
can you post the code where it appears?
Here are all selectors
http://api.jquery.com/category/selectors/
can you post the code where it appears?
My test data
<html>
<head>
<title></title>
<script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>
</head>
<body>
<a/>
<a></a>
<div id="test"></div>
<script>
$("<a/>").html("<span class=\"verdana\">« </span>Prev")
$("#test").html("<span class=\"verdana\">« </span>Prev")
$("a").html("<span class=\"verdana\">« </span>Prev")
</script>
</body>
</html>
@mplungian
If you pass a HTML string to jQuery function, $(), it just generates the DOM element(s), similar to JavaScript createElement(), but you can pass any HTML string with many elements in it.
You need to insert it in the DOM tree in order to see it, using one of jQuery methods like append(), prepend(), insertAfter() and so on.
And... html() does not insert, it replaces the innerHTML.
If you pass a HTML string to jQuery function, $(), it just generates the DOM element(s), similar to JavaScript createElement(), but you can pass any HTML string with many elements in it.
You need to insert it in the DOM tree in order to see it, using one of jQuery methods like append(), prepend(), insertAfter() and so on.
And... html() does not insert, it replaces the innerHTML.
ASKER
Hi, thanks for your post
This does work, I just wanted to understand the syntax a little better.
If you take a look at the following link you'll notice the pagination at the very top of the page. Click a digit or the next button and the "Prev" link appears.
http://www.pc-site.co.uk/dell/#pag
I've added a little more of the script below to help shed some light but due to NDA I can't release the rest, apologies for that.
Thanks again
This does work, I just wanted to understand the syntax a little better.
If you take a look at the following link you'll notice the pagination at the very top of the page. Click a digit or the next button and the "Prev" link appears.
http://www.pc-site.co.uk/dell/#pag
I've added a little more of the script below to help shed some light but due to NDA I can't release the rest, apologies for that.
Thanks again
$("<a/>").html("<span class=\"verdana\">« </span>Prev").attr("href", "#").live( 'click',(function() {
func_tool(tool,tableid,(currpage-1));
return false;
})).appendTo("#pagination").wrap("<span class=\"prev\"></span>");
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
Yes I thought the same about the live()