The <a>
tag is used to create hyperlinks but in this age of jQuery and Ajax we are using it to load HTML into <div>
s in the same page as the <a>
tags.
That said, we set the href
atribute as href="#"
, using or rather abusing the #
character as a placeholder along with some undesirable side effects like the URL getting appended with the #
character.
And if you leave the href
attribute blank href = ""
, the link does not seem to work.
Is there anyway to do this in a cleaner way like showing some text or dummy function in the status bar of the browser when the user hovers over the link and yet make the link do what the programmer intended?
Here s my code.
<ul id="sidebarmenu1">
// List that is converted into a menu...
<li> <a href="#" id="loadHotel" > HOTEL </a> </li>
<li> <a href="#" id="loadCountry"> COUNTRY </a> </li>
<li> <a href="#" id="loadCity"> CITY </a> </li>
</ul>
// The jQuery to load content into another div with Ajax
var loadUrl = "createHotel.php";
$("#loadHotel").click(function() {
$("#mainContent").html(ajax_load).load(loadUrl);
});
// ajax function to load hotel ---> rooms page
var url_loadRooms = "viewRooms.php";
$("#createRooms").click(function() {
$("#mainContent").html(ajax_load).load(url_loadRooms);
});
What else can I use instead of "#"
to make my code neat..?