Allow only one checkbox to get selected on a group of checkbox

HTML:

Ham
Egg
Cheese

Javascript:

$(“input:checkbox”).click(function() {
if ($(this).is(“:checked”)) {
var group = “input:checkbox[name='” + $(this).attr(“name”) + “‘]”;
$(group).prop(“checked”, false);
$(this).prop(“checked”, true);
} else {
$(this).prop(“checked”, false);
}
});

 

Advertisements

window.open().focus()

window.open().focus()

Is used to bring the opened window to the top of the current page , even if you click back an parent page an again trying to open the same opened page.

In Firefox window.open() will open the page to top but when you back and forth from previous page it will hide in the background for solving this we can use .focus() to the window open method.