Just another site

Monthly Archives: April 2016

access javascript object property using variable

I want to assign data to a js object as a property, but the new property name is dynamic.

The bracket notation should be used here:

var apiDynamicString = "dynamicStringFromOtherFunction";

var apiDynamicData ="somedata...";[apiDynamicString] = apiDynamicData ;

Then you can access the property this way:


OR (if you know the variable value)


javascript onclick event not working in chrome

The onclick event for select option is not triggered in chrome. We need to fire the onchange event on the select component.

<select class="select-one-group-select">
 <option class="select-one-group-option" value="option1">option 1</option>
 <option class="select-one-group-option"  value="option2">option 2</option>
 <option class="select-one-group-option"  value="option3">option 3</option>

This doesn’t work:

	$(".select-one-group-option").click(function() {


This solve the problem:

	$(".select-one-group-select").change(function() {