Using jQuery can I get the width of the browser window? Whilst developing a new theme I wished to handle a feature according to the width of the browser. $(window).width(); I like to create my own jQuery variable, with the aim that I shall avoid conflict: var $VNTweb = jQuery.noConflict(); I created a function function […]
Category: JavaScript
Test Whether a Class Exists
jQuery can be used to perform actions on elements within a page which have a class. Or use the class element as a reference point navigating to parents, siblings and child elements. For example its possible to hide all elements which have the class of hideMe. $(‘hideMe’).hide(); What happens if the class element is missing? […]
Accessing Web Page Meta Details
JavaScript can access the web site page meta data through the window document values. Two approaches are taken for the title and the other meta elements. In the example function below the values of the title and description are copied into two DIVs called Headline and Summary respectively. In the short example webpage the function […]
jQuery Test if Element has a Style Value
Looking to test whether an element has a parameter set to a particular value? If you are configuring elements using jQuery you may also wish to see whether you have already set a value. Perhaps using this to determine actions to be taken. I was adding a class to an element to signal that I […]
JavaScript Test if not Undefined
Applying JavaScript actions to an ID, which doesn’t exist, creates an undefined error. As an example consider the following HTML. The DIV has been assigned the id introMain, but is incorrectly referenced in the JavaScript as intromain. <html> <head> <title></title> <meta content=””> <style></style> </head> <body> <div id=”introMain” style=”display:none;” >Intro text </div> <script type=”text/javascript”> var item […]
jQuery Replace Double and Single Quotes
I Wanted to be able to replace the double quotes in a menu with single quotes. For some menu items I was including a double quote around a part of the title. Shown below, are examples entries from the menu <ul class=”dropdown-menu” role=”menu”> <li id=”menu-item-9″><a title=”Carrots” href=”https://localhost/carrots/” class=”dropdown-item”>Carrots</a></li> <li id=”menu-item-1″><a title=””Sprouts”” href=”https://localhost/srouts/” class=”dropdown-item”>“Sprouts”</a></li> <li id=”menu-item-7″><a […]
Resizing the Browser Window
When opening a new browser window the width and height can be set. Not something that I have seen done, so often, for a long time, but which used to be done, was resizing the browser, such that it would fit the content. Resizing the browser window ensures that the content browser window, particularly if […]
jQuery CSS with Multiple Parameters
The jQuery CSS method is used to modify the styling of elements within the HTML page. Typically with the CSS hierarchy these additions will be given highest priority and their addition observed. Most generic descriptions detail how to effect the addition of one of these modifications. But rather than actioning these repeatedly, where more than […]
$.browser is undefined
Following the update of WordPress perhaps a feature in one of the plugins has stopped. Reviewing the page errors with the browser inspector shows the error $.browser is undefined I have also encountered the $.browser is undefined error when I took over a website and updated the jQuery references as a part of my initial […]
Add Scroll Top Image
When the web page has scrolled down an offset distance show a scroll to top image. When redesigning the VNTweb website, thinking about the longer article pages, I chose to add one of these. Scrolling the page down shows on image in a fixed location. Clicking on this image shall scroll the page back to […]