mmazeemahmad 0 Newbie Poster

I want to just bold and underline the (anchor) link when it was clicked with the help of jquery....But didn't know of how to do it.... Here is my code:

<script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $("a").click(function () {

                alert("Hello");

                //                $('.body_text').css('width', '100px');
                //                $('.body_text').css('text-decoration', 'underline');
                //                //this.addClass('makebold');
                //$(this).toggleClass('makebold');
                $(this).css({ "text-decoration": "underline","font-weight": "bold" });
                //$(this).removeClass('makebold');
                //The above code doesn't show this alert is there anything wrong in //writing it as:$('.body_text a').......
                //Some magical code here to bold and underline the selected anchor link //only...
            });
        });
    </script>

<div class="body_wrapper">
    <div id="body_header">
        <div id="body_header_contents_Employees">
            <table cellspacing="18">
                <tr >
                    <td align="center" class="body_text"><a  href="Add_Employee.aspx"><img src="../images/body_header_images/iconEmployees.gif" alt="Add_Employee" title="Add_Employee" border="0" /><br />Add Employee</a></td>
</tr>
</table>
</div></div></div>

the remaining problem is when i use this code and hit the anchor it shows an alert box of hello and makes itself bold and underline too for a fraction of seconds and as soon as the page reload or goes to the href of the anchor all the decoration becomes void.....even if the anchor refer to the same page the decoration becomes void tooo.
what is to be done on page refreshes.............and maintain the decoration of text on it

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.