Specific Keymapping JS [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I'm not super familiar with DOM events and such. Currently, what I'd like to do is click on the first object, which is a HTML link with the class name "test", when the user presses 1 on the keyboard and or keypad as well. I'd be using the keydown event since it seems more supported then keypress. How would I go as to doing this?

Using jquery for example:
$(document).on('keydown', function(event) {
if(event.keyCode == 49 // press key 1 on keyboard
|| event.keyCode == 97) // press key 1 on keypad
location.href = $('a.test').attr('href');
});
jsFiddle

Related

disabling the button. when cells in the schedule are unchecked [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
How to disable the save button when all checkboxes are unchecked, and if at least one hour selected in the schedule will be, the save button becomes active?
Please help.
My code:
https://stackblitz.com/edit/angular-ivy-slrmqc?fbclid=IwAR3mZbHjz8TkLUZJI1kd7gsMnaPikdS0eyGzdF17RPYJ70jyHhXMOzW8x3w&file=src%2Fapp%2Fapp.component.ts
You can add checkIsAllUnchecked method
checkIsAllUnchecked() {
this.isAllUnchecked = this.arr.every((row) =>
row.items.every((col) => col === 0)
);
}
and call it in ngOnInit, click and toggleRow methods
and add the check to the Save button
<button [disabled]="isAllUnchecked" (click)="save()">Save</button>

keypress event on display button by keyboard click [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Needs to activation html button
<td> <input name="Eight" type="Button" class="Gray" value="8" onclick='take("8")' /></td>
by keyboard event, how can I do this?
What mean key in keydownFunction(key)? and doSomething() is function instead take("8") in onclick=? Really dull questions but I'm really don't understand system to call by keyboard events.
You can do this:
onkeydown="keydownFunction()"
If you only want it on a specific key you can do this
onkeydown="keydownFunction(key)"
Then a function that looks like this:
function keyDownFunction(e){
if(e.which == 10){
doSomething();
} else {
return;
}
}
10 will be whatever your key code is, you can figure out what code you need here
http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes

Trigger an enter key against the text field [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm very new to Jquery And I'm trying to stimulate the enter key on a text field. But its not working.
I have an textfield with id deviceSearchByName. I have some text typed in deviceSearchByName and when I press enter search results will be displayed. I'm trying this code from safari console:
var e = jQuery.Event("keydown");
e.which = 13; // Enter
$("#deviceSearchByName").trigger(e)
Its not triggering the enter key event.
Edit:
var e = jQuery.Event("keyup");
e.which = 8; // Enter
$("#deviceSearchByName").trigger(e)
JSFiddle link. In my webpage when I press enter manually (after typing the search keyword) I get the search results. But when I trigger using JS. I dont see any event happened against that textbox and no results are been displayed.
Where I'm making the mistake?
You can see here (http://api.jquery.com/trigger/) that trigger can have two arguments. One for the event and one for extra parameters.
So you need to do :
var e = jQuery.Event("keydown");
e.which = 13; // Enter
$("#deviceSearchByName").trigger('keydown', e);

how to add 2 radio buttons in dialog box in jquery? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need call this on button's click event.
I want to perform further actions based on selected radio button.
$("#btnExport").click( )
Check this link. You need to use .dialog if yo want radiobuttons in dialog
http://jsfiddle.net/6FGqN/813/
from what i understood.. i guess you need trigger
try this
$('#yourbutton').click(function(){
$('#radioID').val();//will give you the selected radio's value
$("#btnExport").trigger('click');
});
I am showing you a simply alert on both buttons. Please change as ur need
<input type="radio" id="btnExport1">
<input type="radio" id="btnExport2">
$("#btnExport1").click(function(){
alert('First Button');
})
$("#btnExport2").click(function(){
alert('Second Button');
})
Demo: http://jsfiddle.net/kapil_dev/tq3Bm/

Javascript: How to change a button to another button? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
If I wanted to take a button and change it to when clicked to another button using javascript, how would I write this in code?
This is all I have so far but its invalid :/
var change = document.getElementById("fire") === document.getElementById("water");
The HTML:
<button onclick="myFunction()" id="fire">fire</button>
<button id="water" style="visibility:hidden">water</button>
JS:
function myFunction()
{
document.getElementById("fire").style.visibility = 'hidden';
document.getElementById("water").style.visibility = 'visible';
}
you should make two buttons.
Make button A visible initially, button B hidden.
When button A is clicked, hide button A and make button B visible.
This can all be done with CSS. Checkout some jQuery tutorials.

Categories