---
tags: javascript
description: Javascript Jquery Tutorial
---
# Javascript Jquery
In this page, I'm going to share some function and problem solving method that often occured in every daily life of a software programmer.
## Q: How can I replace DOM getElementById?
> **A**: Use this function (line 5): ==encodeURIComponent("Dr.A & Dr.B");==
```gherkin=
document.getElementById('contents'); //returns a HTML DOM Object
var contents = $('#contents'); //returns a jQuery Object
```
## Q: Foreach function
> **A**:
```gherkin=
obj.forEach(element => {
newValue.patientID['id' + index] = element;
index++;
});
```
## Q: Add option in select using Foreach function
> **A**:
```gherkin=
$.each(items, function (i, item) {
$('#mySelect').append($('<option>', {
value: item.value,
text : item.text
}));
});
```
## Q: Find selected value in Select option
> **A**:
```gherkin=
var conceptName = $('#aioConceptName').find(":selected").text();
```