Updated Injecting code to UT Pages (markdown)
@@ -46,6 +46,33 @@ if (support === SiteSupport.COURSE_CATALOG_SEARCH) {
|
||||
}
|
||||
```
|
||||
|
||||
# Erasing elements on webpages
|
||||
|
||||
This can be accomplished easily through retrieving elements, for example using `document.getElementById`, and changing their `innerHTML` to `''`
|
||||
|
||||
For example with DaysCheckbox
|
||||
|
||||
```ts
|
||||
const daysDropdown = document.getElementById('mtg_days_st') as HTMLSelectElement | null;
|
||||
if (!daysDropdown) {
|
||||
console.error('Days dropdown not found');
|
||||
return;
|
||||
}
|
||||
|
||||
const formElement = daysDropdown.closest('.form_element')!;
|
||||
const checkboxContainer = document.createElement('div');
|
||||
|
||||
// Create a hidden input to store the value
|
||||
const hiddenInput = document.createElement('input');
|
||||
hiddenInput.type = 'hidden';
|
||||
hiddenInput.name = 'mtg_days_st';
|
||||
hiddenInput.id = 'mtg_days_st_hidden';
|
||||
hiddenInput.value = daysDropdown.value;
|
||||
|
||||
// Remove old dropdown
|
||||
formElement.innerHTML = '';
|
||||
```
|
||||
|
||||
# Examples
|
||||
|
||||
## CourseCatalogMain
|
||||
|
||||
Reference in New Issue
Block a user