Author:
erics , July 22nd, 2021
PROBLEM: An element ID that looked like this would fail to match: service = east node = db1-demo.thedomain.com
< div style = "width: 50px; height: 50px; background: #00aa00; color: #000;" id = "Div-node-notes-east-db1-demo.thedomain.com" > Content to hide and show here < / div >
< a href = "#" onclick = "jQuery('#Div-node-notes-'+service+'-'+node.toggle();return false;" > Toggle Div < / a >
SOLUTION: Rig any special characters in the complex hostname (:.[],-@) with a backslash in front of them to ensure proper matching:
<script>
var G = { } ;
G . cleanid = function ( myid ) {
return myid . replace ( /(:|\.|\[|\]|,|=|@)/g , "\\$1" ) ;
}
</script>
< div style = "width: 50px; height: 50px; background: #00aa00; color: #000;" id = "Div-node-notes-east-db1-demo.thedomain.com" > Content to hide and show here < / div >
< a href = "#" onclick = "jQuery('#Div-node-notes-'+service+'-'+G.cleanid(node).toggle();return false;" > Toggle Div < / a >
Categories: How-To's , Technology Tags: ID , JQuery , Long , Match , onclick , Replace , Script
| No comments
Author:
erics , December 20th, 2018
// include custom jQuery
function wyz_include_custom_jquery ( ) {
wp_deregister_script ( 'jquery' ) ;
wp_enqueue_script ( 'jquery' , 'https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js' , array ( ) , null , true ) ;
}
add_action ( 'wp_enqueue_scripts' , 'wyz_include_custom_jquery' ) ;
Categories: How-To's , Technology Tags: add_action , howto , include , JQuery , Min , tips , WordPress , wp_deregister_script , wp_enqueue_script , wp_enqueue_scripts
| No comments
Author:
erics , March 20th, 2018
window.scrollTo(x-coord, y-coord); Example: window.scrollTo(0,0);
Categories: How-To's , Technology Tags: howto , javascript , JQuery , JS , Scroll , ScrollTo , tips
| No comments
Author:
erics , January 29th, 2014
Edit the wp-config.php file in the root of your WordPress Install. Search for this line: require_once(ABSPATH . ‘wp-settings.php’); Just before it add this line: define(‘CONCATENATE_SCRIPTS’, false ); Save, exit and refresh the page in your browser. It would also be a good idea to empty your browser cache. Original Post: http://www.carnfieldwebdesign.co.uk/blog/wordpress-fix-add-media-button-not-working/
Categories: How-To's , Technology Tags: bug , Bugfix , howto , javascript , JQuery , JS , tips
| No comments
Author:
erics , June 18th, 2013
open : function ( event , ui ) {
jQuery ( '.ui-menu' ) . width ( '220px' ) . css ( 'text-align' , 'left' ) ;
}
Categories: How-To's , Technology Tags: Auto , Autocomplete , Dropdown , howto , javascript , JQuery , jQuery UI , Menu , tips , Width
| No comments
Author:
erics , April 19th, 2013
The jQuery
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
jQuery ( document ) . ready ( function ( ) {
function watchWindow ( ) {
var resizeTimer ;
$ ( window ) . on ( 'resize' , function ( ) {
clearTimeout ( resizeTimer ) ;
resizeTimer = setTimeout ( sizeTable ( ) , 500 ) ;
} ) ;
}
function sizeTable ( ) {
var Mine = { } ;
// calculate the proper number of columns to fit in the available space
Mine . maxColumns = 5 ;
Mine . columnWidth = 232 ;
Mine . tableWidth = jQuery ( '#Table-tiles' ) . width ( ) ;
Mine . windowWidth = jQuery ( window ) . width ( ) ;
//alert('Table: ' + Mine.tableWidth + ', Window: ' + Mine.windowWidth);
Mine . columns = parseInt ( Mine . windowWidth / Mine . columnWidth ) ;
if ( Mine . columns < 1 ) {
Mine . columns = 1 ;
}
if ( Mine . columns > Mine . maxColumns ) {
Mine . columns = Mine . maxColumns ;
}
//alert('Columns: ' + Mine.columns);
// hide or show the columns
for ( var i = 1 ; i < 6 ; i ++ ) {
if ( i > Mine . columns ) {
jQuery ( '#column-' + i ) . hide ( ) ;
} else {
jQuery ( '#column-' + i ) . show ( ) ;
}
}
} ;
sizeTable ( ) ;
watchWindow ( ) ;
} ) ;
The HTML
< table cellpadding = "0" cellspacing = "0" border = "0" style = "margin: 0 auto; " id = "Table-tiles" class = "" >
< tr >
< td id = "column-1" > { $ columns . 1 } < / td >
< td id = "column-2" > { $ columns . 2 } < / td >
< td id = "column-3" > { $ columns . 3 } < / td >
< td id = "column-4" > { $ columns . 4 } < / td >
< td id = "column-5" > { $ columns . 5 } < / td >
< / tr >
< / table >
Categories: How-To's , Technology Tags: JQuery , Responsive , Table
| No comments
Author:
erics , December 16th, 2012
Here is a link to the original article by the Filament Group. I posted the code below just so I have it handy…
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<script>
jQuery . download = function ( url , data , method ) {
//url and data options required
if ( url && data ) {
//data can be string of parameters or array/object
data = typeof data == 'string' ? data : jQuery . param ( data ) ;
//split params into form inputs
var inputs = '' ;
jQuery . each ( data . split ( '&' ) , function ( ) {
var pair = this . split ( '=' ) ;
inputs += '<input type="hidden" name="' + pair [ 0 ] + '" value="' + pair [ 1 ] + '" />' ;
} ) ;
//send request
jQuery ( '<form action="' + url + '" method="' + ( method || 'post' ) + '">' + inputs + '</form>' )
. appendTo ( 'body' ) . submit ( ) . remove ( ) ;
} ;
} ;
</script>
if ( jQuery ( '#Checkbox-download' ) . is ( ':checked' ) ) {
jQuery . download ( '/yourPath/index.php' , 'abc=123' ) ;
return false ;
}
Categories: How-To's , Technology Tags: Download , howto , JQuery , tips
| No comments
Author:
erics , October 4th, 2012
NO Blank Lines!
<script type = "text/javascript" >
< ! --
jQuery ( document ) . ready ( function ( ) {
jQuery ( '#yourForm' ) . on ( 'submit' , function ( e ) {
if ( jQuery ( '#yourInput' ) . val ( ) < 1 ) {
alert ( 'Please enter a whole number greater than 0' ) ;
return false ;
}
} ) ;
} ) ;
//--></script>
Categories: How-To's , Technology Tags: howto , javascript , JQuery , Script , tips , WordPress
| No comments
Author:
erics , October 3rd, 2012
var sum = 0 ;
// loop through each field
jQuery ( ".sum" ) . each ( function ( ) {
//add only if the value is number
if ( ! isNaN ( this . value ) && this . value . length != 0 ) {
sum += parseFloat ( this . value ) ;
}
} ) ;
//.toFixed() rounds the sum to 2 decimal places
jQuery ( "#sum" ) . html ( sum . toFixed ( 2 ) ) ;
Categories: How-To's , Technology Tags: Add , form , howto , JQuery , Math , Sum , tips
| No comments
Author:
erics , September 8th, 2012
var Tag = jQuery(‘yourElementSelector’).get(0).tagName.toLowerCase(); Note: nodeName also works in place of tagName!
Categories: How-To's , Technology Tags: GET , get(0) , howto , JQuery , nodeName , tagName , tips , toLowerCase
| No comments