找到 732 篇 与 jQuery 相关的文章
541 次浏览
jQuery.getJSON( url, [data], [callback] ) 方法使用 GET HTTP 请求从服务器加载 JSON 数据。以下是此方法所用所有参数的说明:url — 包含要向其发送请求的 URL 的字符串data — 此可选参数表示将发送到服务器的键/值对。callback — 此可选参数表示在成功加载数据时执行的函数。假设我们在 result.json 文件中有以下 JSON 内容:{ "name": "David", "age" : "25", "sex": "male" }以下代码片段显示了如何使用... 阅读更多内容
7,000+ 次浏览
要使用 jQuery 和 Ajax 从 JSON 文件中提取数据,请使用 jQuery.getJSON( url, [data], [callback] )jQuery.getJSON (url, [data], [callback])方法使用 GET HTTP 请求从服务器加载 JSON 数据。以下是此方法使用的所有参数的说明url − 一个包含向其发送请求的 URL 的字符串data -此可选参数表示将发送到服务器的键/值对。callback -此可选参数表示一个函数,每当数据被成功加载就会执行该函数。假设我们有 result.json 文件中的以下 JSON 内容 −{ "name": "John", "age": ... 阅读更多
17K+ 查看
要使用 jQuery 加载 JSON 数据,请使用 getJSON() 和 ajax() 方法。jQuery.getJSON ()方法使用 GET HTTP 请求从服务器加载 JSON 数据。以下是此方法使用的所有参数的说明url − 一个包含向其发送请求的 URL 的字符串data -此可选参数表示将发送到服务器的键/值对。callback -此可选参数表示一个函数,每当数据被成功加载就会执行该函数。将 JSON 内容添加到 result.json 文件中 −{ "name": "Amit", "age":"27","sex": "male" }以下是显示代码段的代码段... 阅读更多
0 Views
To load an external HTML into using jQuery, use the attr() method. In that set the source for iframe. You can try to run the following code to learn how to locate external HTML −ExampleLive Demo $(document).ready(function(){ $('#iframe').attr('src', 'https://www.qries.com'); });
3K+ Views
To change the background image using jQuery, use the jQuery css() method. The background-image CSS property is used to change background image.ExampleYou can try to run the following code to learn how to change background image using jQuery:Live Demo $(document).ready(function(){ $("body").on({ mouseenter: function(){ $(this).css("background-image", "url('/css/images/css.jpg')"); }, }); }); Move the mouse pointer on the page to change the background image.
284 Views
jQuery on() methodThe on( events [, selector ] [, data ], handler ) method binds a handler to an event (like click) for all current − and future − matched element. It can also bind custom events.Here is the description of all the parameters used by this method −events − Event types separated by spaces.selector − A Selector Stringdata − Data to be passed to the event handler in event.datahandler − A function to bind to the event on each of the set of matched elementsExampleYou can try to run the following code to learn how to work with on() method − ... Read More
534 Views
To disable a particular jQuery event, use the jQuery off() method. You can try to run the following code to learn how to disable a particular jQuery event on a page −ExampleLive Demo $(document).ready(function(){ $("p").on("click", function(){ alert("You clicked it!"); }); $("button").click(function(){ $("p").off("click"); }); }); Click me Click above to generate an alert box. Click the below button to remove namespace, which won’t generate an alert box. Remove Event
7K+ Views
To submit a form using jQuery click event, you need to detect the submit event. Let’s submit a form using click event and without using click event.ExampleYou can try to run the following code to learn how to submit a form using jQuery click event −Live Demo $(document).ready(function(){ $(function() { $('#submit1').click(function(e) { e.preventDefault(); $("#Demo").submit(); }); $('#submit2').click(function(e) { e.preventDefault(); $("#Demo").submit(); }); }); }); Team Submit
6K+ Views
To set the background color using jQuery, use the jQuery css() property. We will set background color on mouse hover with the jQuery on() method.ExampleYou can try to run the following color to set background color in jQuery.Live Demo $(document).ready(function(){ $("body").on({ mouseenter: function(){ $(this).css("background-color", "gray"); }, }); }); Move the mouse pointer on the page to change the background color.