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 , June 30th, 2015
/opt/aws/bin/ec2-metadata | grep placement
Categories: How-To's , Technology Tags: Amazon , Availability Zone , AWS , AZ , cli , ec2-metadata , howto , ID , Instance , Instance ID , meta , metadata , Placement , Region , tips , Zone
| No comments
Author:
erics , October 1st, 2012
Add the parameter label_ids=true. For example:
{ html_radios name = "yourName" label_ids = true options = $ yourOptions selected = $ smarty . request . yourName separator = "<br/>" }
Categories: How-To's , Technology Tags: howto , html , html_radios , ID , Missing , php , Radio , Radio Button , Radios , Smarty , tips
| No comments
Author:
erics , September 20th, 2011
Here is a VERY simplistic watermark code snippet. It has the distinct disadvantage of submitting the watermark string as the field value, and does not set the initial field value either…YMMV…
jQuery ( '#yourInput' )
. focusin ( function ( ) {
if ( jQuery ( '#yourInput' ) . val ( ) == 'Enter keywords to search for' ) jQuery ( '#yourInput' ) . val ( '' ) ;
} )
. focusout ( function ( ) {
if ( jQuery ( '#yourInput' ) . val ( ) == '' ) jQuery ( '#yourInput' ) . val ( 'Enter keywords to search for' ) ;
} ) ;
http://api.jquery.com/focusin/
Categories: How-To's , Technology Tags: Focus , focusin , focusout , form , Form field , howto , ID , input , Input field , JQuery , tips , val() , Water Mark , Watermark
| No comments
Author:
erics , August 19th, 2011
Ran into an odd issue matching the id attribute in jQuery when it is extra-long. Seems like the syntax: jQuery(‘#LongIDNameGoesHere’) doesn’t match long ID’s, when the syntax: jQuery(‘[id^=LongIDNameGoesHere]’) does match correctly. Not entirely sure yet why this is, but figured it is best to document the facts as I found them…
Categories: How-To's , Technology Tags: ID , id length , id too long , JQuery , Match
| No comments
Author:
erics , July 2nd, 2011
var WhichButton ;
jQuery ( 'button' ) . live ( 'click' , function ( ) {
WhichButton = this . id ;
} ) ;
jQuery ( 'form' ) . live ( 'submit' , function ( ) {
alert ( 'Button ID: ' + WhichButton ) ;
return false ;
} ) ;
Categories: How-To's , Technology Tags: Button , Find , form , howto , ID , JQuery , Submit , tips
| No comments
Author:
erics , May 10th, 2011
Use the .length property:
if ( jQuery ( "#yourDiv" ) . length > 0 ) {
// your code here
}
Categories: How-To's , Technology Tags: Exists , ID , JQuery , Length
| No comments