当前位置:网站首页>JS-BOM-Name Converter - Input Name Position Reversed
JS-BOM-Name Converter - Input Name Position Reversed
2022-08-08 14:36:00 【(-^_^-)】
All string methods:
Use index of indexOf()
Extract string: substring()
Returns the character at the specified position: charAt()
function hanshu(){var n =document.getElementById('1');name=n.value; //The name is the content entered in the text boxvar spaceIndex=name.indexOf(" ");//Return the index position of the first spacevar firstName=name.substring(0,spaceIndex);//The first wordvar laterName=name.substring(spaceIndex+1);//Extract the word after removing the first spacespaceIndex=laterName.indexOf(" ");//Return the index position where the first space is removedvar SecondName=laterName.substring(0,spaceIndex);//The second wordvar lastName=laterName.substring(spaceIndex+1);n.value=lastName + " "+SecondName+ " "+firstName;}
边栏推荐
猜你喜欢
年初离职,学习半年源码,终于拿到了蚂蚁Offer,分享面试过程
logistic regression model - based on R
路由器——交换机——网络交换机:区别
京东三面惨遭被虐,关于redis,高并发,分布式,问懵了
Shell Three Musketeers-----sed command
开源一夏 | 自己画一块ESP32-C3 的开发板(PCB到手)
基于SCL语言的模拟量平均值滤波FB库功能介绍及创建FB库的具体方法
华为云弹性云服务器ECS使用【华为云至简致远】
HMS Core Analysis Service Intelligent Operation Version 6.5.1 Launched
shell regular expression, Three Musketeers grep command
随机推荐
【索引】图神经论文之GCN(持更)
设计一个跨平台的即时通讯系统(采用华为云ECS服务器作为服务端 )【华为云至简致远】
我凭借这份pdf成功拿到了阿里,腾讯,京东等六家大厂offer
shell------常用小工具,sort,uniq,tr,cut
在中国银河证券开户安全吗 齐齐哈尔股票开户
面试题 17.05. 字母与数字
路由器——交换机——网络交换机:区别
【控制】动力学建模举例 --> 牛顿-欧拉法
LeetCode Daily Question 2022/8/1-2022/8/7
一打是多少个?
【小码匠自习室】重做ABC250-D, 我无力反抗
什么是发饰hair accessories?
手把手教你设计一个全局异常处理器
Code Casual Recording Notes_Dynamic Programming_322 Change Exchange
kali换源详细步骤
优雅地实时检测和更新 Web 应用
华为云会议初体验【华为云至简致远】
【小码匠自习室】[NOI Online 2020-2 入门组] 未了:可恶的精度会让你焦头烂额
【小码匠自习室】 [NOI Online 2022 入门组] 王国比赛
【小码匠自习室】ABC084 - D:喜欢这样的大神,超有才华