How to catch x and y position and reposition exactly in MVC4?

Possible Duplicate: Dynamically retrieve the position (X,Y) of an HTML element In a MVC4 app (targeting IE7+) I have an image. I want the user to be able to click on the image to position a little marker (image), and I want to store the relative x/y position related to the image so that I can reposition this pin when the user returns to this page again. What is the best way to accomplish t

如何捕捉x和y的位置,并精确地在MVC4中重新定位?

可能重复: 动态检索HTML元素的位置(X,Y) 在一个MVC4应用程序(针对IE7 +),我有一个图像。 我希望用户能够点击图像来定位一个小标记(图像),并且我想存储与图像相关的相对x / y位置,这样我可以在用户返回此页面时重新定位此引脚再次。 什么是完成这个最好的方法? 你可以使用一个<input type="image" />标签 - 这就像<input type="submit" />但它将点击的x和y坐标发送回服务器

How to know element position while it move

This question already has an answer here: Get mouse position within div? [duplicate] 3 answers Retrieve the position (X,Y) of an HTML element 23 answers The pageX / pageY variables in the event object refers to the mouse position. If you want to get the position of the element you should do something like this: $(document).on('mousemove', function(e) { var element = $('#myDiv');

移动时如何知道元素的位置

这个问题在这里已经有了答案: 在div中获取鼠标位置? [重复] 3个答案 检索HTML元素的位置(X,Y)23的答案 event对象中的pageX / pageY变量引用鼠标位置。 如果你想获得元素的位置,你应该这样做: $(document).on('mousemove', function(e) { var element = $('#myDiv'); console.log( element.offset() ); // returns an object with x/y coordinates of the top-left corner of the element }); 查看.

Element destination

This question already has an answer here: Retrieve the position (X,Y) of an HTML element 23 answers Try this: window.onload = function() { console.log(document.getElementById("id1").offsetTop); }; where id1 is the id of the textbox you need to triangulate.

元素目的地

这个问题在这里已经有了答案: 检索HTML元素的位置(X,Y)23的答案 尝试这个: window.onload = function() { console.log(document.getElementById("id1").offsetTop); }; 其中id1是您需要进行三角化的文本框的ID。

Get position off all divs

This question already has an answer here: Retrieve the position (X,Y) of an HTML element 23 answers Try with this: var divs = window.frames[0].document.getElementsByTagName("div") i = 0, rects = []; for (; i < divs.length; i++) rects.push(divs[i].getBoundingClientRect()); Now the array rects contains objects that define the position relative to the viewport of all your divs. Eac

获取所有div的位置

这个问题在这里已经有了答案: 检索HTML元素的位置(X,Y)23的答案 试试这个: var divs = window.frames[0].document.getElementsByTagName("div") i = 0, rects = []; for (; i < divs.length; i++) rects.push(divs[i].getBoundingClientRect()); 现在,数组rects包含定义相对于所有div的视口的位置的对象。 每个元素都是这样的: { top: ..., right: ..., bottom: ..., left: ..., w

Absolute .position() value

This question already has an answer here: Retrieve the position (X,Y) of an HTML element 23 answers From the jquery docs: The .position() method allows us to retrieve the current position of an element relative to the offset parent. Contrast this with .offset(), which retrieves the current position relative to the document. http://api.jquery.com/position/ So use .offset() .

绝对.position()值

这个问题在这里已经有了答案: 检索HTML元素的位置(X,Y)23的答案 从jquery文档: .position()方法允许我们检索元素相对于偏移父级的当前位置。 将它与.offset()进行对比,该文件检索相对于文档的当前位置。 http://api.jquery.com/position/ 所以使用.offset() 。

what's the exact way to get the position of an element?

This question already has an answer here: Retrieve the position (X,Y) of an HTML element 23 answers 试试这个:http://www.quirksmode.org/js/findpos.html

获得元素位置的确切方法是什么?

这个问题在这里已经有了答案: 检索HTML元素的位置(X,Y)23的答案 试试这个:http://www.quirksmode.org/js/findpos.html

Find X/Y of an HTML element with JavaScript

This question already has an answer here: Retrieve the position (X,Y) of an HTML element 23 answers 以下是我的做法: // Based on: http://www.quirksmode.org/js/findpos.html var getCumulativeOffset = function (obj) { var left, top; left = top = 0; if (obj.offsetParent) { do { left += obj.offsetLeft; top += obj.offsetTop; } while (obj = obj.off

使用JavaScript查找HTML元素的X / Y

这个问题在这里已经有了答案: 检索HTML元素的位置(X,Y)23的答案 以下是我的做法: // Based on: http://www.quirksmode.org/js/findpos.html var getCumulativeOffset = function (obj) { var left, top; left = top = 0; if (obj.offsetParent) { do { left += obj.offsetLeft; top += obj.offsetTop; } while (obj = obj.offsetParent); } return {

How to make the main content div fill height of screen with css

This question already has an answer here: Make a div fill the height of the remaining screen space 31 answers no height in % is needed no jQuery is needed (!) stretch div using bottom & top : .mainbody{ position: absolute; top: 40px; /* Header Height */ bottom: 20px; /* Footer Height */ width: 100%; } check my code : http://jsfiddle.net/aslancods/mW9W

如何使主要内容div用CSS填充屏幕高度

这个问题在这里已经有了答案: 让div填充剩余屏幕空间的高度31个答案 不需要%的高度 不需要jQuery (!)使用bottom&top展开div: .mainbody{ position: absolute; top: 40px; /* Header Height */ bottom: 20px; /* Footer Height */ width: 100%; } 检查我的代码:http://jsfiddle.net/aslancods/mW9WF/ 没有JavaScript,没有绝对定位,没有固定的高度是必需的这一个。 以下

Yea or nay?

Recently I have been reading more and more about people using custom attributes in their HTML tags, mainly for the purpose of embedding some extra bits of data for use in javascript code. I was hoping to gather some feedback on whether or not using custom attributes is a good practice, and also what some alternatives are. It seems like it can really simplify both server side and client side c

是或不是?

最近我一直在阅读越来越多关于在HTML标签中使用自定义属性的人,主要是为了嵌入一些额外的数据以用于JavaScript代码。 我希望收集一些关于是否使用自定义属性的良好做法的反馈,以及其他替代方法。 它似乎可以真正简化服务器端和客户端代码,但它也不符合W3C标准。 我们是否应该在我们的Web应用程序中使用自定义HTML属性? 为什么或者为什么不? 对于那些认为自定义属性是好事的人来说:使用它们时需要注意哪些事项?

What is the difference between JavaScript's getElementById() and getElementsByName() functions?

Other than the fact that my brief research tells me the latter will return a collection rather than aa single element with the ID passed. Consider the following code: function validateAllFields() { var clientid = document.getElementById("clientid"); var programs = document.getElementById("programs"); var startmonth = document.getElementById("startmonth"); var startday = document.getElementById

JavaScript的getElementById()和getElementsByName()函数有什么区别?

除了我的简短研究告诉我后者将返回一个集合而不是传递ID的单个元素。 考虑下面的代码: function validateAllFields() { var clientid = document.getElementById("clientid"); var programs = document.getElementById("programs"); var startmonth = document.getElementById("startmonth"); var startday = document.getElementById("startday"); var startyear = document.getElementById("startyear"); var completed = d