Sue White
asked on
jquery to set html title tag from span element
I am trying to set an html page <title> tag with text on the page. The page is a dynamic page, so I want the page title to change depending on the dynamic page opened - which will have different text on every page.
I'm close to getting this to work - but I need help with my jquery syntax. I don't fully understand how to set this with jquery, so I'd appreciate a little information about how/why your recommendation will work vs. what I did that is almost working.
This is my script:
This is what renders in the title tag and browser tab (in correctly displaying [object Object])
This is how the text on the page is wrapped on the page:
<tr>
<td class="ms-vb" width="25%"></td>
<td class="ms-vb" width="75%">
<span class="resourcetitle"></sp an>
</td>
</tr>
Thank you in advance for a reply.
tag1.png
I'm close to getting this to work - but I need help with my jquery syntax. I don't fully understand how to set this with jquery, so I'd appreciate a little information about how/why your recommendation will work vs. what I did that is almost working.
This is my script:
<script>
$(document).ready(function () {
var strTitle = $('.resourcetitle');
$(document).attr('title', strTitle);
});
</script>
This is what renders in the title tag and browser tab (in correctly displaying [object Object])
This is how the text on the page is wrapped on the page:
<tr>
<td class="ms-vb" width="25%"></td>
<td class="ms-vb" width="75%">
<span class="resourcetitle"></sp
</td>
</tr>
Thank you in advance for a reply.
tag1.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for the accurate and speedy reply
You are welcome. Glad to help, and thanks for the points!
ASKER