开发者

Javascript store locator to Jquery

I'm in 开发者_StackOverflow社区a bit of a rut. I need to figure out how to convert all this code into jquery. Since I don't know too much jquery. http://www.lastyearsloss.com/store/javascript/map.js I'm not sure which lines I can use or which ones change fully. The main problem is where I'm importing the data from xml. If anyone can point me in the right direction that would be awesome! thanks!


How will jQuery fix your importing of data? jQuery is still Javascript, just with shortcuts. It may make your code shorter to help you fix your problem;

from

var sidebar = document.getElementById('sidebar');
sidebar.innerHTML = '<p class="caption">No results found.</p>';
var div = document.createElement('li');

to

var sidebarJquery = $('#sidebar')
                      .html('<p class="caption">No results found.</p>');
var divJquery = $('<li/>');

A jQuery object is basically an Array of DOM elements, (with some additional methods), so:

var sidebar = sidebarJquery[0];
var div = divJquery[0];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜