copy all contents of a td to another in another div [duplicate] - php

This question already has answers here:
jQuery copying content between DIVs
(4 answers)
Closed 9 years ago.
I do need to know how to copy the contents of an entire html td td and play for another from a different button that was clicked?
both the button when the content comes from the database
was thinking about this for jquery but not know where to start: (

This should go with:
$('td').clone().appendTo('.newtd');
you trigger that with eg following:
$('#triggerbtn').click(function() {
$('td').clone().appendTo('.newtd');
}
markup for the button:
<div id="triggerbtn">Click me for clone</div>
the .newtd is the class of the new td you want to clone your content. you can use an id declared with a #newtd as well.

Related

How to add my html javascript popup to my php function? [duplicate]

This question already has answers here:
Accessing session from TWIG template
(5 answers)
Closed 9 months ago.
I want to add my javascript popup code which is in an html file to my php function.
It's a visitor counter in php. I want when visitors visit the page 4 times my popup html js is displayed
Do you just mean like this?
if ($increment == true) {
$compteur_actuel = $session->get('compteurClicsFreemium', 0);
$session->set('compteurClicsFreemium', $compteur_actuel+1);
if ($compteur_actuel > 4) {
?>
<div>
Your HTML code here
</div>
<?php
}
}

Is it possible to apply jquery to content rendered by external php (ajax)? [duplicate]

This question already has answers here:
Events triggered by dynamically generated element are not captured by event handler
(5 answers)
Closed 8 years ago.
page-one.php contains such jquery
$.post("___for_ajax_process.php", data_to_send_ajax_post, function(data_edit_content) {
$('#show_result').html(data_edit_content);
});
in #show_result i see content from ___for_ajax_process.php
Rendered content contains many checkboxes and want to create check all. check all is named draft_check_all.
At first want to check what happens if I click the checkbox.
$("#draft_check_all").click(function(){
alert ( 'click test' );
});
And I do not see alert ( 'click test' ); No popup at all.
Then View source and I do not see source code for content rendered by ___for_ajax_process.php
As understand in such way can not apply jquery to content from ___for_ajax_process.php? What if place $("#draft_check_all").click(function(){ in ___for_ajax_process.php? Are there any solutions for such situation?
Solution
placed jquery in external php and all works!
A better solution would be event delegation.
$('#show_result').on('click', '#draft_check_all', function () {
...
});

Get Anchor tag class/id from table jQuery [duplicate]

This question already has answers here:
How to get the id of an anchor tag in jQuery?
(3 answers)
Closed 8 years ago.
I have a table like this
I need to get the anchor tag value(class or id) from the table.
In other words, how to get the anchor tag value using jQuery
<table class="kimztableclass" id="kimztableid">
<tr>
<a class="kimzanchorclass" id="kimzanchorid" >Kimz Value</a>
</tr>
</table>
I need something like this
$(document).ready(function() {
$('.mytableanchortagclass').editable({
.........do my coding stuff.................
}
}
});
});
In short - I need to get the anchor tag id/name inorder to proceed with my jQuery stuff.
Thanks,
Kimz
use
For getting class name
$(".kimztableclass a").attr("class");
For getting Id
$(".kimztableclass a").attr("id");
For getting text
$(".kimztableclass a").text();
use attr() method
$('.mytableanchortagclass tr').find('a').attr('id')
This will return all anchor tag with class kimzanchorclass:
$('a.kimzanchorclass').attr('id');

Is it possible to increase the number of rows of a textarea using Javascript event? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to change the number of rows in the textarea using jQuery
I'm trying to build a comment box that simulates Facebook, where Shift+Enter increases the rows in the textarea while Enter submits the form. I already can capture both events correctly, I'm just wondering if Javascript alone can edit a page's element attributes since it has already been loaded, or if there's another way to do it.
EDIT:
My code block looks like this:
$(this).keypress(function(e) {
if (e.which == 13 && e.shiftKey) {
this.rows++;
e.preventDefault();
};
});
But this still doesn't seem to work. Again, I've tried placing alerts into this code block so I'm certain the Shift+Enter event is captured, but the textarea's rows just doesn't increase. Any ideas why? :/
$("textarea").keydown(function(e) {
if(e.shiftKey&&e.keyCode==13) {
this.rows++;
}
})

how can change value of a div [duplicate]

This question already has answers here:
How can I convert language of a div?
(4 answers)
Closed 7 years ago.
"<div id="diva">this is div a</div>"
"<div id="divb"> this is div b</div>"
now how can I change the text of div dynamically by button click. here also mention that all text come from a database. when I click the button then it detects the div id and replace the text with desire text.
All code will be in PHP.
This will work once the page is being loaded:
document.getElementById('diva').innerHTML =
<?php echo functionThatReturnsSomeValue(); ?>;
Dynamically, you would need to do an AJAX call on the PHP file which outputs a value. You'd be better off if you used a JS framework such as jQuery, rather than implementing the AJAX call yourself.
PHP cannot modify the content of the page after it has been served to the browser. However this would be trivial with a JavaScript Library such as jQuery.

Categories