简体   繁体   English

信息显示在一个div中,同时按下另一个div中的按钮,而无需通过jQuery&PHP加载页面

[英]Information shows in a div while pressing button from another div without loading page by jQuery & PHP

At first I apologize for not having the code of my desire & I've no idea how I'll ask the exact question by focusing any specific keywords. 起初,我为没有我想要的代码而道歉,我也不知道如何通过集中任何特定的关键字来询问确切的问题。

However, I want to show my product information in an area(div) whenever I click a button in another area(div). 但是,每当我单击另一个区域(div)中的按钮时,我想在区域(div)中显示我的产品信息。 & The work should be done without refreshing pages. &应该在不刷新页面的情况下完成工作。

Again I apologize for that I've not the code. 我再次为我没有代码表示歉意。 But I can provide an image and hope you'll understand my desire 但我可以提供一张图片,希望您能理解我的愿望 在此处输入图片说明

Example : Whenever I click on angry burger , the price and quantity should be shown in the right(California Fried Chicken) area. 示例 :每当我单击“ 愤怒的汉堡”时 ,价格和数量应显示在右侧(加利福尼亚炸鸡)区域。 And multiple selecting product should also work one by one. 多种选择的产品也应该一一工作。 After that I should be able to submit product information bu pressing submit button where a PHP operation should be done. 之后,我应该能够通过按提交按钮(其中应该执行PHP操作)来提交产品信息。

I want to do the whole task by jQuery & PHP 我想通过jQuery和PHP完成整个任务

Thanks 谢谢

You can achieve this by setting up click listeners in your javascript/jquery code and assign them to the ids of your pictures or fields. 您可以通过在javascript / jquery代码中设置点击侦听器并将它们分配给图片或字段的ID来实现。 For example you can assign an id to an tag like below; 例如,您可以为标签分配一个ID,如下所示;

<p id="div">Hello world</p>

And then set up a click event in your jquery code to execute a function whenever that tag is clicked 然后在您的jquery代码中设置一个click事件,以在每次单击该标签时执行一个函数

$( "#div" ).bind( "click", function() {
          var tag = $(this).html(); //get the value of the tag
         alert(tag);//this will display Hello world
});

You can do this for any tag and retrieve its value or contents or anything and carry out an activity like changing the display of another element as below 您可以对任何标签执行此操作,并检索其值或内容或其他任何内容,并执行如下所示的更改其他元素的显示等活动

$("#change").append(tag) //this will change the display of the tag with id change 

Please ask if you have any questions 请问您有什么问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM