0

Possible to make, that by one mouse click 2 buttons will be clicked? I mean if buttons If are on each other.

enter image description here

I've tried to hide (set opaticy to 0) one of them, but only one is clicked which one is in front.

Maybe could I use pointer-events, but I don't know how to make It successfully? Or It impossible at all?

I've tried pointer-events: none;, but It disabled one button at all. So could you help me, please? Thank you.

5 Answers5

0

suppose you have two buttons like:

<input type="submit" name="savebutton" class="first button" />
<input type="submit" name="savebutton" class="second button" />

Now you just need to create a jquery function to trigger second button on the click of first button:

jQuery("input.first").click(function(){
   // trigger second button by javascript
    $(".second").click();
   return false;
});
Nitin Jain
  • 3,053
  • 2
  • 24
  • 36
Priya jain
  • 753
  • 2
  • 5
  • 15
  • @NitinJ Thank you for answer, but jQuery doesn't work for me, I don't know why. I've tried copy/paste this http://jsfiddle.net/gdoron/WTzKR/ and this http://jsfiddle.net/wpELC/2/ to my blank page PHP page, but It not alert anything. –  Dec 24 '13 at 17:37
0

if you want to call event function on different element it's much easier to use separate functions:

var clickFunction1 = function(e) {
   // e.target will have targeted element if you need it
   // some code
   clickFunction2(e);
}

var clickFunction2 = function(e) {
   // some code
   clickFunction1(e);
}

$('#button-1').click(clickFunction1);
$('#button-2').click(clickFunction2);

jsfiddle: http://jsfiddle.net/g9K6N/

Also if I'm not mistaken if user performs event you can call click event yourself too

$('#button-1').click(function() {
    $('#button-2').click();
});
Artem L
  • 10,123
  • 1
  • 20
  • 15
0

you can call click of second by javascript

$("#first button id").click(function(){
 $("#second button id").click();
})
Nitin Jain
  • 3,053
  • 2
  • 24
  • 36
  • Thank you for answer, but jQuery doesn't work for me, I don't know why. I've tried copy/paste this http://jsfiddle.net/gdoron/WTzKR/ and this http://jsfiddle.net/wpELC/2/ to my blank page PHP page, but It not alert anything. –  Dec 24 '13 at 17:35
  • have you include jquery.js in the head – Nitin Jain Dec 24 '13 at 17:42
0
function GetAllElementsAt(x, y) {
    var $elements = $("body *").map(function() {
        var $this = $(this);
        var offset = $this.offset();
        var l = offset.left;
        var t = offset.top;
        var h = $this.height();
        var w = $this.width();

        var maxx = l + w;
        var maxy = t + h;

        return (y <= maxy && y >= t) && (x <= maxx && x >= l) ? $this : null;
    });

    return $elements;
}
Robbie Bardijn
  • 483
  • 2
  • 6
0

just Copy And Paste this code...

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
  $("#my-group :button").click(function(){
    alert('testing...');
  });
});
</script>
<div id="my-group">
    <input type="button" name="Finish" value="Finish">
    <input type="button" name="Update" value="Update">
    <input type="button" name="Cancel" value="Cancel">
</div>

<div id="not-my-group">
    <input type="button" name="Finish" value="Finish">
    <input type="button" name="Update" value="Update">
    <input type="button" name="Cancel" value="Cancel">
</div>
Priya jain
  • 753
  • 2
  • 5
  • 15