jQuery checkbox checked state changed event
July 25, 2014
Bind to the change event instead of click. However, you will probably still need to check whether or not the checkbox is checked: Example below shows and hide a div when checkbox checked or unchecked
PHP replace spaces in urls image name
July 21, 2014
Looking to replace all instances of spaces in urls with %20? No need for a regex. Use rawurlencode() instead urlencode() for this purpose. Example: urlencode($img) will result It will not change to %20. But with rawurlencode($img), it produce Another way of doing it is using str_replace
Jquery read element attribute id with square brackets [ ]
July 16, 2014
To use any of the meta-characters ( such as !”#$%&’()*+,./:;?@[\]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id=”foo.bar”, can use the selector $(“#foo\\.bar”). Example: Reference: Special Characters In Selectors
PHP sort multidimensional Array by specific key value
July 14, 2014
Try usort for multidimensional array sorting by specific key value inside each sub array. Example: The best way is: reference: http://stackoverflow.com/questions/2699086/sort-multidimensional-array-by-value-2
Bootstrap responsive Youtube Youku video embed
July 14, 2014
The bootstrap is not a magic tool, its just a layout engine. Just use the grid provided by bootstrap and remove strict width on the iframe. Use the bootstrap class guides replace the width. For better view of the video, may keep the height. Youtube: Youku example:
FUELPHP Form Checkbox checked
July 1, 2014
FuelPHP checkbox is not a nightmare if understand it’s parameters correctly. The syntax is checkbox($field, $value = null, $checked = null, $attributes = array()) To built form checkbox, simply do like below: Will output a checked checkbox: To uncheck the checkbox, changed the ‘checked’ value to empty ” or null
jquery validator addmethod custom message
June 3, 2014
Custome message can be added in the validator addMethod, example below, the $.validator.messages.currency_limit carry the different message for different condition.
Checking if an array key exists in a JavaScript object or array
June 3, 2014
For the sake of completeness, you can use the in operator. This is probably the best way to check for missing keys.
jQuery set element style to the :hover css style
June 3, 2014
jQuery has .hover function which will freeze the hover effect. It’d be better to just give that state another class itself in the CSS and then use your method to add that class. You may keep the id of the div and control the css changes using class
jQuery how to know if div with specific id exists
June 3, 2014
To check if the div with specific id or class exist, you can use .length after the selector to see if it matched any elements, like this:
Recent Comments