首页 \ 问答 \ DOM对象的jQuery xy文档坐标(jQuery x y document coordinates of DOM object)

DOM对象的jQuery xy文档坐标(jQuery x y document coordinates of DOM object)

我需要得到一个DOM元素的X,Y坐标(相对于文档的顶部/左边)。 我找不到任何可以给我的插件或jQuery属性或方法。 我可以获取DOM元素的顶部和左侧,但可以相对于其当前的容器/父或文档。


I need to get the X,Y coordinates (relative to the document's top/left) for a DOM element. I can't locate any plugins or jQuery property or method that can give these to me. I can get the top and left of the DOM element, but that can be either relative to its current container/parent or to document.


原文:https://stackoverflow.com/questions/1002934
更新时间:2022-06-05 10:06

最满意答案

删除尾随的分号:

#define RESTFUL_PATH_PREFIX @"https://gogch.com/gch-restful";
                                                            ^

然后字符串常量可以由编译器连接:

@"first" @"second"

代替:

@"first"; @"second"

Remove the trailing semi-colon:

#define RESTFUL_PATH_PREFIX @"https://gogch.com/gch-restful";
                                                            ^

and then string constants can be concatenated by the compiler:

@"first" @"second"

instead of:

@"first"; @"second"

相关问答

更多
  • 它很简单: 对于ObjC: NSString *string1 = @"This is"; NSString *string2 = @"Swift Language"; ForSwift: let string1 = "This is" let string2 = "Swift Language" 对于ObjC AppendString: NSString *appendString=[NSString stringWithFormat:@"%@ %@",s ...
  • 删除尾随的分号: #define RESTFUL_PATH_PREFIX @"https://gogch.com/gch-restful"; ^ 然后字符串常量可以由编译器连接: @"first" @"second" 代替: @"first"; @"second" Remove the trailing semi-colon: #define RESTFUL_PATH_PREFIX ...
  • 如果您正在使用std :: strings,请使用stringstream: #include #include using namespace std; string oldString = "old"; int toAppend = 5; stringstream ss(toAppend); string newString = oldString + ss.str(); "old5"将是"old5" Use stringstream if you are wo ...
  • 如果j从1变为4,它将覆盖播放器名称(在第二个循环中播放时,播放器也将被打印4次)...首先, j应该从2到4 ......其次是Cells(i, 1).Value = strPlayer应该在第二个循环之外......第三个:你已经有了附加部分。 把你已经拥有的所有东西合并在一起,我得到了这个: Sub New_Entry() Dim strPlayer As String, strTick As Integer, i As Integer, j As Integer strPlayer = In ...
  • 您可以自己进行扩展: if(STRCMP(some_string, "==", " blabla")) if((strcmp(some_string, " blabla") "==" 0 )) 不幸的是,我认为在"=="附近引用它会使其不正确,并且很可能无法编译。 正确的语法是: if(STRCMP(some_string, ==, " blabla")) 这是一个测试,通过使用==或!=比较来查看变量some_string代表文本" blabla" 。 (与C中的其他值一样) You can do ...
  • 注意:在您的问题中,每行末尾都有分号。 这将严重干扰任何使用这些宏的尝试。 所以这取决于找到DECLARE_CMD(...)行的位置和方式,以及是否可以修复分号问题。 如果它们只是一个专用的头文件,你可以这样做: #define DECLARE_CMD(func, arg) &func, my_func_type my_funcs [] { #include "file_with_declare_cmd.h" }; ......变成了: my_func_type my_funcs [] { ...
  • 你必须再次评估str的参数才能看到字符串中的10 #define LEN 10 #define str_(x) #x #define str(x) str_(x) 你这样做的方式, str的参数是直接stringyfied,因此LEN到达格式。 You'd have to evaluate the argument to str once more to see the 10 inside the string #define LEN 10 #define str_(x) #x #d ...
  • 在C语言中,函数没有可移植的方式来知道它的调用者。但是你是对的,宏观的工作方式是: #define smart_log(...) ( printf("[%s]: ", __func__) , printf(__VA_ARGS__) ) __func__被定义(C99 / C11 __func__ p.1) 就好像紧接在每个函数定义的开始大括号后面的声明一样 static const char __func__ [] = " function-name "; 出现了,其中function-name是词法封闭 ...
  • 正如NSGod所说, NSString上有几个方法可以连接和返回字符串。 但是,如果您计划多次追加,则可能需要使用NSMutableString ,它针对此类情况进行了优化。 例如(根据您尝试解决的问题): NSMutableString *str = [NSMutableString string]; for (int iterator = 0; iterator < count; iterator++) { if (array[iterator] != 0) { [str ap ...
  • 你的宏在( “ , ” )中有智能引号,而不是真正的引号( " )。 此外,作为一个良好的实践,在定义周围放置一个括号,和x ,例如: #define GET_RED_TEXT(x) ("\x1B[31m" (x) "\x1B[00m") Your macro has smart quotes in (“, ”) not real quotes ("). Also, as a matter of good practice, put a bracket round the definition, and ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)