Some notes about creating visible and invisible buttons in Knockout.js.
Some notes about creating visible and invisible buttons in Knockout.js.
There's an equivalent in jQuery to PHP function print_r($array). It's good when you want to see an associative array. Especially, if you get it via some function.
Useful snippet for debugging javascript. It prints out key-value pairs of associative array. In PHP your have function print_r($array), but in Javascript you still have to make your own function.
If you want to apply the same action for multiple selectors in jQuery, you should write down their identificators separated by comma. It can be as simple ID of elements, their classes or something more difficult.
There's a common constraint in votes or surveys like "choose no more than 3 items". And it's not a good idead to allow user control the checked items quantity. You can easily set constraint to a quantity of checked checkbox items with JavaScript and jQuery. You can just disable unchecked checkbox items if user checked maximum quantity and enables items again in case of unchecking.
Strange behavior of console.log() I have noticed when I created a JS code for SharePoint page. My code used jQuery and SPServices library. The code used to get items from a list and render options for "select" control.
Below I post a part of my function which fills a JS array and renders options for "select" control.
If you want to set the same action for several elements, you can write IDs of elements separated by comma. This way:
It took me some time to get the index of selected value of <select> html control. I tried to use 'attr', but 'prop' should be used for this.
Tables with at least 20 rows are more readable when its rows look like stripes – even row in one color, odd one in another. Before jQuery we used to add class to each row of table, we made "<tr class="even"> …</tr>" and "<tr class="odd"> …</tr>". Now it’s much easier to do using jQuery. (read more...)
Below I described two string javascript functions that I often forget. (read more...)