onclick

Why is the onclick event on the body element not working?

一个人想着一个人 提交于 2020-01-13 06:04:29
问题 I'm trying to send users to another page when click html body: JavaScript c.js : function clickBody(){ window.location.href = '/'; } HTML: <!DOCTYPE html> <html> <head> <script src="c.js"></script> </head> <body onclick="clickBody();"> </body> </html> I can run the function from console, but clicking the <body> is not working. 回答1: <body> element have no height, add something like bellow: <!DOCTYPE html> <html> <head> <style> body { height: 500px; } </style> <script src="c.js"></script> <

Run jQuery function onclick

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-12 05:22:28
问题 so i implemented a bit of jQuery that basically toggles content via a slider that was activated by an <a> tag. now thinking about it id rather have the DIV thats holding the link be the link its self. the jQuery that i am using is sitting in my head looks like this: <script type="text/javascript"> function slideonlyone(thechosenone) { $('.systems_detail').each(function(index) { if ($(this).attr("id") == thechosenone) { $(this).slideDown(200); } else { $(this).slideUp(600); } }); } </script> i

Get value of List Item with jQuery

限于喜欢 提交于 2020-01-12 04:44:08
问题 How to get value and index of list item onClick event with jQuery? for example: <ul id='uItem'> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> <li>Item 4</li> </ul> 回答1: Combine the use of .index() and .text() (or .html(), if you wish): $('#uItem li').click(function() { var index = $(this).index(); var text = $(this).text(); alert('Index is: ' + index + ' and text is ' + text); }); 回答2: $('#uItem li').click(function(){ var $this = $(this); alert('Text ' + $this.text() + 'Index ' + $this

Implement onClick only for a TextView compound drawable

别来无恙 提交于 2020-01-12 04:01:10
问题 I need to have some text with a drawable on the left and I want to execute some code when the user clicks/touches the image (only the image, not the text), so I used a LinearLayout with a TextView and an ImageView which is clickable and launches an onClick event. The XML parser suggests me to replace this with a TextView with a compound drawable , which would draw the same thing with far less lines of XML .. My question is "can I specify I want to handle an onClick event only on the drawable

Android views expand animation

三世轮回 提交于 2020-01-12 03:58:07
问题 I'm trying to edit these source to create a simple function that will work on all of my views. @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); RelativeLayout mLayout1 = (RelativeLayout) findViewById(R.id.layout1); RelativeLayout mLayoutToBeExpanded1 = (RelativeLayout) findViewById(R.id.layout_exp_1); addAction(mLayout, mLayoutToBeExpanded); RelativeLayout mLayout2 = (RelativeLayout) findViewById(R.id.layout2);

Play audio and restart it onclick

杀马特。学长 韩版系。学妹 提交于 2020-01-12 01:45:13
问题 I'm looking to restart an audio file in a HTML5 audio player. I have defined a audio file and a play button. <audio id="audio1" src="01.wav"></audio> <button onClick="play()">Play</button> When I click the play button the audio file starts playing, but when I click the button again the audio file doesn't stop and will not play again until it reaches the end of the file. function play() { document.getElementById('audio1').play(); } Is there a method that would allow me to restart the audio

change event not working for a textbox when the value is assigned externally

情到浓时终转凉″ 提交于 2020-01-11 10:49:12
问题 I have a textbox and a button. When I click the button, it sets certain value in the textbox. I want to submit the page whenever the value of the textbox is changed. Please check here HTML: <input type='text' class="set" size=50> <input type="button" id="click" value="Click" /> JQuery: $(document).ready(function () { $("input").change(function () { alert("Changed!"); }); $("#click").click(function () { $('.set').val('Why am I not getting the alert saying - Changed! '); }); }); I am able to

Why is my onclick event not registered in Firefox?

守給你的承諾、 提交于 2020-01-11 08:50:31
问题 I have a list item with an onclick event. It runs in Chrome and Internet Explorer, but not Firefox. Any suggestions? <li onclick="alert('test');">test test<br></li> 回答1: This works fine for me in Firefox. Check this: JavaScript is enabled in your browser. Try adding a return false; statement in your tag. Or a function like this: function test() { //your code here return false; } Or use this: <a href="#" onclick="alert('hi');">Link</a> or this <a href="javascript:void(0)" onclick="alert('hi');

OSMDroid: onTap example

情到浓时终转凉″ 提交于 2020-01-11 06:15:06
问题 I've started to study Android few weeks ago and now I need your help. My task is create off-line map (using OSMDroid and Mobile Atlas Creator), with two markers on it, path between them and some activity after clicking on this markers. I've done map, markers and path. Here is the code (Android 2.3.3): public class MainActivity extends Activity { private MapView mapView; LocationManager locationManager; ArrayList<OverlayItem> overlayItemArray; @Override public void onCreate(Bundle

OSMDroid: onTap example

徘徊边缘 提交于 2020-01-11 06:14:26
问题 I've started to study Android few weeks ago and now I need your help. My task is create off-line map (using OSMDroid and Mobile Atlas Creator), with two markers on it, path between them and some activity after clicking on this markers. I've done map, markers and path. Here is the code (Android 2.3.3): public class MainActivity extends Activity { private MapView mapView; LocationManager locationManager; ArrayList<OverlayItem> overlayItemArray; @Override public void onCreate(Bundle