<solved> Center icon,search by ENTER key and 'target="_blank"'

<solved> Center icon,search by ENTER key and 'target="_blank"'
0

#1

Hi Campers,

My wikipedia viewer project is getting to the end, three things needs to be done for now.

1, How to center the search icon in the button? this issue bothers me a lot ever since i used icon in button.
I tried “vertical-align:middle” which does not change anything in this case.

2, How to set the output (searching results) links to open in a new tab?
I use .append() to add the elements to my result list. so in my html file, I don’t actually have a anchor tag to put target="_blank".

3, How to submit search by ENTER key?

Thanks!


#2

1 - that is really weird, there is a problem with the html layout you used, when you using something like an input and a button to submit what ever the typed in the input you should put this inside of a form.

2- inside the anchor tag without quotes.

3- by putting the button and the input inside a form it will submit when you press enter automatically , but you will have to change the way you are handling this in your jquery, you should listen to a OnSubmit event on the form and use preventDefaultI() to prevent the page from reloading , that what it does when you submit something via form.

in case you have never done a submit form before
https://www.w3schools.com/html/html_forms.asp

how to prevent default on submit using jquery


#3

#4

I use .append() to add the elements to my result list. so in my html file, I don’t actually have a anchor tag to put target="_blank".


#6

Thanks. I see you also fixed my reload issue, i was so frustrated.:slight_smile:


#7

Well im on my cell and icant check your code right now, but if i remember correctly inside your append() there was an anchor tag


#8

Oh, I see. Thanks! didn’t think of that.