<script>
function autoSelect(elem) {
var selection, range;
if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(elem);
selection.removeAllRanges();
selection.addRange(range);
} else if (document.selection) { // IE
selection = document.selection.createRange().text;
range = document.body.createTextRange();
range.moveToElementText(elem);
range.select();
}
document.execCommand('copy');
}
// Eksekusi di sini
$('#btn').on("click", function() {
autoSelect($('#result')[0]);
});
</script>
Showing posts with label JQuery. Show all posts
Showing posts with label JQuery. Show all posts
Monday, September 14, 2015
Monday, July 6, 2015
How to work with jQuery AJAX and PHP array return
In your PHP code encode the array as JSON object
Then you need to convert the JSON object into a Javascript/jQuery-compatible object. Afterwards you can convert back to an array
|
Monday, June 22, 2015
JQuery : div hide on click outside of selectore
$(document).click(function(event) {
if (!$(event.target).closest('#list-column,#col-btn').length) {
// Hide the menus.
$('#list-column').hide(200);
}
});
if (!$(event.target).closest('#list-column,#col-btn').length) {
// Hide the menus.
$('#list-column').hide(200);
}
});
Friday, June 19, 2015
jQuery: Get the contents of a table row with a button click
<script>
$(".use-address").click(function() {
var $row = $(this).closest("tr"); // Find the row
var $text = $row.find(".nr").text(); // Find the text
// Let's test it out
alert($text);
});
</script>
<table id="choose-address-table" class="ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header ">
<th>Name/Nr.</th>
<th>Street</th>
<th>Town</th>
<th>Postcode</th>
<th>Country</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<tr>
<td class="nr"><span>50</span>
</td>
<td>Some Street 1</td>
<td>Glasgow</td>
<td>G0 0XX</td>
<td>United Kingdom</td>
<td>
<button type="button" class="use-address" />
</td>
</tr>
<tr>
<td class="nr">49</td>
<td>Some Street 2</td>
<td>Glasgow</td>
<td>G0 0XX</td>
<td>United Kingdom</td>
<td>
<button type="button" class="use-address" />
</td>
</tr>
</tbody>
</table>
$(".use-address").click(function() {
var $row = $(this).closest("tr"); // Find the row
var $text = $row.find(".nr").text(); // Find the text
// Let's test it out
alert($text);
});
</script>
<table id="choose-address-table" class="ui-widget ui-widget-content">
<thead>
<tr class="ui-widget-header ">
<th>Name/Nr.</th>
<th>Street</th>
<th>Town</th>
<th>Postcode</th>
<th>Country</th>
<th>Options</th>
</tr>
</thead>
<tbody>
<tr>
<td class="nr"><span>50</span>
</td>
<td>Some Street 1</td>
<td>Glasgow</td>
<td>G0 0XX</td>
<td>United Kingdom</td>
<td>
<button type="button" class="use-address" />
</td>
</tr>
<tr>
<td class="nr">49</td>
<td>Some Street 2</td>
<td>Glasgow</td>
<td>G0 0XX</td>
<td>United Kingdom</td>
<td>
<button type="button" class="use-address" />
</td>
</tr>
</tbody>
</table>
Hide/Show Column in an HTML Table
<script>
function fire() {
var v = $('#number').val() || "" || 0;
$('#foo tr > :nth-child('+v+')').toggle();
}
$('button').click(fire);
</script>
<table id="foo">
<tr><td>1</td><td>hide</td><td>3</td><td>4</td></tr>
<tr><td>1</td><td>3</td><td>3</td><td>4</td></tr>
<tr><td>1</td><td>3</td><td>3</td><td>4</td></tr>
<tr><td>1</td><td>3</td><td>3</td><td>4</td></tr>
<tr><td>1</td><td>3</td><td>3</td><td>4</td></tr>
</table>
<input id="number" value="2">
<button>Toggle</button>
function fire() {
var v = $('#number').val() || "" || 0;
$('#foo tr > :nth-child('+v+')').toggle();
}
$('button').click(fire);
</script>
<table id="foo">
<tr><td>1</td><td>hide</td><td>3</td><td>4</td></tr>
<tr><td>1</td><td>3</td><td>3</td><td>4</td></tr>
<tr><td>1</td><td>3</td><td>3</td><td>4</td></tr>
<tr><td>1</td><td>3</td><td>3</td><td>4</td></tr>
<tr><td>1</td><td>3</td><td>3</td><td>4</td></tr>
</table>
<input id="number" value="2">
<button>Toggle</button>
Monday, September 8, 2014
Submit Without Refresh Page
<script src="jquery.js" type="text/javascript"></script>
<script src="jquery.form.js" type="text/javascript"></script>
<script src="jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
$('document').ready(function(){
$('#add_frm_jurnal').validate({
submitHandler: function(form){
$(form).ajaxSubmit({ target: '#tampilanform', success: function() {alert('ok'); } });
}
})
});
</script>
<script src="jquery.form.js" type="text/javascript"></script>
<script src="jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
$('document').ready(function(){
$('#add_frm_jurnal').validate({
submitHandler: function(form){
$(form).ajaxSubmit({ target: '#tampilanform', success: function() {alert('ok'); } });
}
})
});
</script>
Tuesday, December 3, 2013
key for place absolute div element to mouse posistion when clicked
<script>
function supplier_detile(){
var e = window.event;
$('#supplier_detile').offset({left:e.pageX -450,top:e.pageY+15}).show(800 ).offset({left:e.pageX -450,top:e.pageY+15});loadsupp lierdetile('supplier');documen t.getElementById('supplier_det ile').style.zIndex='99';
}
</script>
function supplier_detile(){
var e = window.event;
$('#supplier_detile').offset({left:e.pageX -450,top:e.pageY+15}).show(800
}
</script>
Subscribe to:
Posts (Atom)