Link Methods
The following methods are available in the jQuery and Backbone objects for link controls.
link.getHref()
The link.getHref()
method returns the URL (address) of the hyperlink.
Example:
When the user enters a new value in the "productName" textbox, verify that the new product name is also found in the link with the ID "productLink".
var productUrl = encodeURIComponent(newVal);
//search for product name in product link
if ($("#productLink").getHref().search(productUrl) == -1)
alert("Warning: Product name '" +productUrl+ "' is not found in product link.");
}
link.setHref()
The link.setHref()
method sets the URL (address) in a hyperlink.
Example:
When the user enters a new value in the "productName" textbox, set the link to use the product name in a link with the ID "productLink".
var productUrl = encodeURIComponent(newVal);
var url = "http://www.acme.com/product/" + productUrl;
$("#productLink").setHref(url);
}